Comments (4)
Hey @Erreur32 that's super odd. I just tested on my machine by creating a script that simply echos that JSON output, and the agent accepts it and generates a sensor.
The "could not unmarshal script output" means the agent couldn't parse the output as either JSON, TOML or YAML (i.e., it doesn't recognise the output). Maybe the script is outputting some strange/unexpected whitespace?
You can use dasel to validate the JSON output of the script. Once you have dasel installed, a command like:
/home/debian32/.config/com.github.joshuar.go-hass-agent/scripts/check_version_ha_agent_json.sh > /tmp/script.output.json && dasel validate /tmp/script.output.json && rm /tmp/script.output.json
Should print out pass /tmp/script.output.json
or a fail (some error)...
if it failed to validate.
If it is possible, can you share the script and I can see if I can reproduce with the actual script?
from go-hass-agent.
Good point for validiting the json.
Very strange i have copy paste on online checking , and no error , but yes with dasel i sow the issue ;)
dasel validate .config/com.github.joshuar.go-hass-agent/version_installed.json
fail .config/com.github.joshuar.go-hass-agent/version_installed.json could not unmarshal data: could not decode object: invalid character '\x1b' in string literal
Error: 1 files failed validation
And apparently, the go-hass-agent version output also returns this ANSI control sequence along with the actual version.
--> "7.3.1[0m"
So I filtered it and now it seems to work :)
sed 's/\x1B\[[0-9;]*[a-zA-Z]//g'
my working script (for example propose):
#!/bin/bash
generate_json_output() {
script_name="go hass agent version_installed"
script_version=$(sudo -u debian32 /home/debian32/.local/bin/go-hass-agent version | grep -oP '(?<=go-hass-agent: ).*' | sed 's/\x1B\[[0-9;]*[a-zA-Z]//g')
last_update=$(date "+%Y-%m-%d %H:%M:%S%z")
# Creation JSON file (in case of)
cat <<EOF > /home/debian32/.config/com.github.joshuar.go-hass-agent/version_installed.json
{
"schedule": "@every 1h",
"sensors": [
{
"sensor_name": "$script_name",
"sensor_icon": "mdi:package",
"sensor_state": "$script_version",
"sensor_attributes": {
"last_updated": "$last_update"
}
}
]
}
EOF
}
generate_json_output
cat /home/debian32/.config/com.github.joshuar.go-hass-agent/version_installed.json
Working well now, see my sensor :)
Question:
I have changed sensor's name, and now i see 2 sensors in HA, the last one is ok , but how can i remove the old one ?
There is a cache somewhere ?
from go-hass-agent.
I'm glad it's now working! Yes, the output of the version command has some escape sequences to colour the output:
As an alternative to your script, I could add a sensor that shows the agent version that only updates whenever the agent is started?
Hmm, I think you can only remove a sensor if it is no longer provided by whatever was sending it. Otherwise you could just hide it. You can follow the instructions for customising entities:
Select the entity, either from the frontend or by selecting the info button next to the entity in the Developer Tools “States” tab.
Select the cog icon in the right corner of the entity’s dialog.
Toggle the "Enabled", "Visible" switches, or click "DELETE" depending on your preference.
from go-hass-agent.
As an alternative to your script, I could add a sensor that shows the agent version that only updates whenever the agent is started?
As there is no automatic update, this seems like a good idea to me.
i have made a card and script to check online version on Github also:
from go-hass-agent.
Related Issues (20)
- Add Suspend to MQTT HOT 9
- go-hass-agent errors out on first run HOT 14
- Add sensor and switch for connected monitor
- [FEATURE REQUEST] Audio control HOT 1
- [BUG] Wrong config path for mqtt HOT 8
- MQTT auto-reconnect HOT 8
- Unsupported or unknown portal. App sensors will not run. HOT 5
- [BUG] Panic caused by sending on closed channel HOT 2
- [BUG] Network offline state not correctly reported to HA HOT 1
- [BUG] Crash with script (invalid memory address or nil pointer dereference) HOT 4
- [BUG] go-hass-agent does not creat state folder for log file, crashes therefore on fresh install. HOT 2
- [BUG] Not all drives are recognised / not named recognisable HOT 16
- [BUG] v8.0.0 don't have any .tar.xz release for Debian. HOT 4
- [FEATURE REQUEST] deactivate swap if non is present HOT 1
- [BUG] device gets overwritten from another one (identical hardware different hostname) HOT 4
- [BUG] HOT 2
- [BUG] v9.0.0 release is missing debian x86 .deb files HOT 2
- [SENSOR] Add an IsDocked sensor HOT 1
- [BUG] Preferences area is empty HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-hass-agent.