hjelev / rpi-mqtt-monitor

Raspberry Pi MQTT Monitor gathers system information and sends it to a MQTT server.
GNU General Public License v3.0
155 stars 41 forks source link

Entity update not working #113

Open WarC0zes opened 2 months ago

WarC0zes commented 2 months ago

Hi, The update entity doesn't work. I'm in version 0.9.1 and it still tells me 0.8.9. image image image

However, if I look at the information in rpi-mqtt-monitor, I am in version 0.9.1. rpi-mqtt-monitor2

The update entity image is missing. If I connect to the image link, it tells me "Folder not found". I'm using a local image in the meantime.

hjelev commented 2 months ago

How did you installed and updated the script? Looking at the last screenshot I think you updated fine and home assistant just needs some time to sync. If hass don't sync its because this command below is failing (before running it update path-to-repo with the path to rpi-mqtt-monitor folder)

/usr/bin/git -C path-to-repo ls-remote --tags origin | awk -F'/' '{{print $3}}' | sort -V | tail -n 1

WarC0zes commented 2 months ago

How did you installed and updated the script?

I did an automatic install, and run in service.

bash <(curl -s https://raw.githubusercontent.com/hjelev/rpi-mqtt-monitor/master/remote_install.sh)

I updated with:

python3 src/update.py

and too

python3 src/rpi-cpu2mqtt.py -u

If hass don't sync its because this command below is failing (before running it update path-to-repo with the path to rpi-mqtt-monitor folder) /usr/bin/git -C path-to-repo ls-remote --tags origin | awk -F'/' '{{print $3}}' | sort -V | tail -n 1

image

I even removed the device from MQTT, restarted the RPI. The device adds well but the update entity still remains on 0.8.9.

WarC0zes commented 2 months ago

after 24h, the installed version 0.9.1 appeared. But the last version is 0. image

binary_sensor always on, even though I am up to date. image image

slawekzz commented 2 months ago

after update from command line i have error /rpi-mqtt-monitor# python3 src/update.py

Current version: 0.9 :: Updating git repository /root/rpi-mqtt-monitor/src Already up to date.

Traceback (most recent call last): File "/root/rpi-mqtt-monitor/src/update.py", line 93, in do_update(script_dir,check_git_version_remote(script_dir)) File "/root/rpi-mqtt-monitor/src/update.py", line 83, in do_update if display_config_differences(script_dir + '/config.py', script_dir + '/config.py.example') and config_update: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/rpi-mqtt-monitor/src/update.py", line 37, in display_config_differences current_assignments = get_assignments(current_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/rpi-mqtt-monitor/src/update.py", line 10, in get_assignments assignments = {node.targets[0].id: ast.literal_eval(node.value) for node in ast.walk(tree) if isinstance(node, ast.Assign)} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/rpi-mqtt-monitor/src/update.py", line 10, in assignments = {node.targets[0].id: ast.literal_eval(node.value) for node in ast.walk(tree) if isinstance(node, ast.Assign)} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 110, in literal_eval return _convert(node_or_string) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 109, in _convert return _convert_signed_num(node) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 83, in _convert_signed_num return _convert_num(node) ^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 74, in _convert_num _raise_malformed_node(node) File "/usr/lib/python3.11/ast.py", line 71, in _raise_malformed_node raise ValueError(msg + f': {node!r}') ValueError: malformed node or string on line 51: <ast.Call object at 0xffff9d697130>

hjelev commented 2 months ago

Hi, try the new version 0.9.2 - this error should not appear, also why are you installing the script as root?

WarC0zes commented 2 months ago

after update from command line i have error /rpi-mqtt-monitor# python3 src/update.py

Current version: 0.9 :: Updating git repository /root/rpi-mqtt-monitor/src Already up to date.

Traceback (most recent call last): File "/root/rpi-mqtt-monitor/src/update.py", line 93, in do_update(script_dir,check_git_version_remote(script_dir)) File "/root/rpi-mqtt-monitor/src/update.py", line 83, in do_update if display_config_differences(script_dir + '/config.py', script_dir + '/config.py.example') and config_update: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/rpi-mqtt-monitor/src/update.py", line 37, in display_config_differences current_assignments = get_assignments(current_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/rpi-mqtt-monitor/src/update.py", line 10, in get_assignments assignments = {node.targets[0].id: ast.literal_eval(node.value) for node in ast.walk(tree) if isinstance(node, ast.Assign)} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/rpi-mqtt-monitor/src/update.py", line 10, in assignments = {node.targets[0].id: ast.literal_eval(node.value) for node in ast.walk(tree) if isinstance(node, ast.Assign)} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 110, in literal_eval return _convert(node_or_string) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 109, in _convert return _convert_signed_num(node) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 83, in _convert_signed_num return _convert_num(node) ^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/ast.py", line 74, in _convert_num _raise_malformed_node(node) File "/usr/lib/python3.11/ast.py", line 71, in _raise_malformed_node raise ValueError(msg + f': {node!r}') ValueError: malformed node or string on line 51: <ast.Call object at 0xffff9d697130>

Hi, your problem has nothing to do with this issue. Open an issue to your problem, so as not to pollute my issue, thank you.

@hjelev the update entity doesn't work, the latest version remains at 0 and the changelog link is not good. image

hjelev commented 2 months ago

@WarC0zes looking at the screenshots i see that your system is not using English, it should be something related to the language, I'll look again. I have checked and there is nothing language related in the update part. Since you are failing to get the remote version it might be an issue with the script installation path (this is the only information my script is auto populating in the command that you executed and returned the correct version) I have added some more information to rpi-mqtt-monitor -d output. Please do a git pull from the script folder to get the new code and show me the output of rpi-mqtt-monitor -d . The other thing i can suggest you is to delete the script folder and try a fresh installation of the script.

WarC0zes commented 2 months ago

@WarC0zes looking at the screenshots i see that your system is not using English, it should be something related to the language, I'll look again. I have checked and there is nothing language related in the update part. Since you are failing to get the remote version it might be an issue with the script installation path (this is the only information my script is auto populating in the command that you executed and returned the correct version) I have added some more information to rpi-mqtt-monitor -d output. Please do a git pull from the script folder to get the new code and show me the output of rpi-mqtt-monitor -d . The other thing i can suggest you is to delete the script folder and try a fresh installation of the script.

here's output

warc0zes@raspberrypi:~/rpi-mqtt-monitor/src $ git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 7 (delta 3), reused 5 (delta 3), pack-reused 0
Unpacking objects: 100% (7/7), 2.54 KiB | 83.00 KiB/s, done.
From https://github.com/hjelev/rpi-mqtt-monitor
   7fa9eba..1d356c9  master     -> origin/master
Updating 7fa9eba..1d356c9
Fast-forward
 install.sh          | 2 ++
 src/rpi-cpu2mqtt.py | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
warc0zes@raspberrypi:~/rpi-mqtt-monitor $ python3 src/rpi-cpu2mqtt.py -d

:: rpi-mqtt-monitor
   Version: 0.9.2

:: Device Information
   Model Name: Raspberry Pi 3 Model B Rev 1.2
   Manufacturer: Raspberry Pi
   OS: Debian GNU/Linux 11 (bullseye)
   Hostname: raspberrypi
   IP Address: 192.168.1.34
   MAC Address: B8-27-xx-xx-xx
   Update Check Interval: 3600 seconds

:: Measured values
   CPU Load: 6.5 %
   CPU Temp: 32 °C
   Used Space: 10 %
   Voltage: 1.2 V
   CPU Clock Speed: False MHz
   Swap: False %
   Memory: 21 %
   Uptime: 15 days
   Wifi Signal: 93 %
   Wifi Signal dBm: False
   RPI5 Fan Speed: False RPM
   Update: {"installed_ver": "0.9.2", "new_ver": "0.9.2"}
   Installation directory: /home/warc0zes/rpi-mqtt-monitor/src

:: Release notes 0.9.2:
### What's Changed

* Update readme.md by @hjelev in #112
* Adds backslashes to fix python syntax warning by @metheos in #117
* bug fixes by @hjelev in #118

* New Contributors

* @metheos made their first contribution in #117
hjelev commented 2 months ago

This looks good, the script is able to pull the correct url and release notes. If the update is not working after you restart the service - like below sudo service rpi-mqtt-monitor restart The issue should be in the service file running the script - pls show me the content of your service file located in /etc/systemd/system/rpi-mqtt-monitor.service

WarC0zes commented 2 months ago

This looks good, the script is able to pull the correct url and release notes. If the update is not working after you restart the service - like below sudo service rpi-mqtt-monitor restart

restart the service, not working. sudo service rpi-mqtt-monitor restart

The issue should be in the service file running the script - pls show me the content of your service file located in /etc/systemd/system/rpi-mqtt-monitor.service

Type=simple
Restart=always
NotifyAccess=none
RestartUSec=5s
TimeoutStartUSec=1min 30s
TimeoutStopUSec=1min 30s
TimeoutAbortUSec=1min 30s
TimeoutStartFailureMode=terminate
TimeoutStopFailureMode=terminate
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestampMonotonic=0
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=688
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success
ReloadResult=success
CleanResult=success
UID=0
GID=0
NRestarts=0
OOMPolicy=stop
ExecMainStartTimestamp=Sat 2024-05-25 09:27:26 BST
ExecMainStartTimestampMonotonic=21793857
ExecMainExitTimestampMonotonic=0
ExecMainPID=688
ExecMainCode=0
ExecMainStatus=0
ExecStart={ path=/home/warc0zes/rpi-mqtt-monitor/rpi_mon_env/bin/python3 ; argv[]=/home/warc0zes/rpi-mqtt-monitor/rpi_mon_env/bin/python3 /home/warc0zes/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py --service ; ignore_errors=no ; start_ti>
ExecStartEx={ path=/home/warc0zes/rpi-mqtt-monitor/rpi_mon_env/bin/python3 ; argv[]=/home/warc0zes/rpi-mqtt-monitor/rpi_mon_env/bin/python3 /home/warc0zes/rpi-mqtt-monitor/src/rpi-cpu2mqtt.py --service ; flags= ; start_time=[Sat >
Slice=system.slice
ControlGroup=/system.slice/rpi-mqtt-monitor.service
MemoryCurrent=[not set]
CPUUsageNSec=13278060000
EffectiveCPUs=
EffectiveMemoryNodes=
TasksCurrent=4
IPIngressBytes=[no data]
IPIngressPackets=[no data]
IPEgressBytes=[no data]
IPEgressPackets=[no data]
IOReadBytes=18446744073709551615
IOReadOperations=18446744073709551615
IOWriteBytes=18446744073709551615
IOWriteOperations=18446744073709551615
Delegate=no
CPUAccounting=yes
CPUWeight=[not set]
StartupCPUWeight=[not set]
CPUShares=[not set]
StartupCPUShares=[not set]
CPUQuotaPerSecUSec=infinity
CPUQuotaPeriodUSec=infinity
AllowedCPUs=
AllowedMemoryNodes=
IOAccounting=no
IOWeight=[not set]
StartupIOWeight=[not set]
BlockIOAccounting=no
BlockIOWeight=[not set]
StartupBlockIOWeight=[not set]
MemoryAccounting=yes
DefaultMemoryLow=0
DefaultMemoryMin=0
MemoryMin=0
MemoryLow=0
MemoryHigh=infinity
MemoryMax=infinity
MemorySwapMax=infinity
MemoryLimit=infinity
DevicePolicy=auto
TasksAccounting=yes
TasksMax=779
IPAccounting=no
ManagedOOMSwap=auto
ManagedOOMMemoryPressure=auto
ManagedOOMMemoryPressureLimitPercent=0%
Environment=HOME=/home/warc0zes
UMask=0022
LimitCPU=infinity
LimitCPUSoft=infinity
LimitFSIZE=infinity
LimitFSIZESoft=infinity
LimitDATA=infinity
LimitDATASoft=infinity
LimitSTACK=infinity
LimitSTACKSoft=8388608
LimitCORE=infinity
LimitCORESoft=0
LimitRSS=infinity
LimitRSSSoft=infinity
LimitNOFILE=524288
LimitNOFILESoft=1024
LimitAS=infinity
LimitASSoft=infinity
LimitNPROC=2598
LimitNPROCSoft=2598
LimitMEMLOCK=8388608
LimitMEMLOCKSoft=8388608
LimitLOCKS=infinity
LimitLOCKSSoft=infinity
LimitSIGPENDING=2598
LimitSIGPENDINGSoft=2598
LimitMSGQUEUE=819200
LimitMSGQUEUESoft=819200
LimitNICE=0
LimitNICESoft=0
LimitRTPRIO=0
LimitRTPRIOSoft=0
LimitRTTIME=infinity
LimitRTTIMESoft=infinity
WorkingDirectory=/home/warc0zes/rpi-mqtt-monitor
RootHashSignature=
OOMScoreAdjust=0
CoredumpFilter=0x33
Nice=0
IOSchedulingClass=0
IOSchedulingPriority=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
CPUAffinity=
CPUAffinityFromNUMA=no
NUMAPolicy=n/a
NUMAMask=
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardInputData=
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SyslogLevel=6
SyslogFacility=3
LogLevelMax=-1
LogRateLimitIntervalUSec=0
LogRateLimitBurst=0
SecureBits=0
CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin cap_net_raw cap_ipc_lo>
AmbientCapabilities=
User=root
DynamicUser=no
RemoveIPC=no
MountFlags=
PrivateTmp=no
PrivateDevices=no
ProtectClock=no
ProtectKernelTunables=no
ProtectKernelModules=no
ProtectKernelLogs=no
ProtectControlGroups=no
PrivateNetwork=no
PrivateUsers=no
PrivateMounts=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=no
UtmpMode=init
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=2147483646
LockPersonality=no
RuntimeDirectoryPreserve=no
RuntimeDirectoryMode=0755
StateDirectoryMode=0755
CacheDirectoryMode=0755
LogsDirectoryMode=0755
ConfigurationDirectoryMode=0755
TimeoutCleanUSec=infinity
MemoryDenyWriteExecute=no
RestrictRealtime=no
RestrictSUIDSGID=no
RestrictNamespaces=no
MountAPIVFS=no
KeyringMode=private
ProtectProc=default
ProcSubset=all
ProtectHostname=no
KillMode=control-group
KillSignal=15
RestartKillSignal=15
FinalKillSignal=9
SendSIGKILL=yes
SendSIGHUP=no
WatchdogSignal=6
Id=rpi-mqtt-monitor.service
Names=rpi-mqtt-monitor.service
Requires=system.slice -.mount sysinit.target
Wants=network-online.target
WantedBy=multi-user.target
Conflicts=shutdown.target
Before=multi-user.target shutdown.target
After=-.mount basic.target sysinit.target systemd-journald.socket network-online.target system.slice
RequiresMountsFor=/home/warc0zes/rpi-mqtt-monitor
Description=RPI MQTT Monitor
LoadState=loaded
ActiveState=active
FreezerState=running
SubState=running
FragmentPath=/etc/systemd/system/rpi-mqtt-monitor.service
UnitFileState=enabled
UnitFilePreset=enabled
StateChangeTimestamp=Sat 2024-05-25 09:27:26 BST
StateChangeTimestampMonotonic=21796146
InactiveExitTimestamp=Sat 2024-05-25 09:27:26 BST
InactiveExitTimestampMonotonic=21796146
ActiveEnterTimestamp=Sat 2024-05-25 09:27:26 BST
ActiveEnterTimestampMonotonic=21796146
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
CanFreeze=yes
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=no
NeedDaemonReload=no
JobTimeoutUSec=infinity
JobRunningTimeoutUSec=infinity
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Sat 2024-05-25 09:27:26 BST
ConditionTimestampMonotonic=21786593
AssertTimestamp=Sat 2024-05-25 09:27:26 BST
AssertTimestampMonotonic=21786613
Transient=no
Perpetual=no
StartLimitIntervalUSec=10s
StartLimitBurst=5
StartLimitAction=none
FailureAction=none
SuccessAction=none
InvocationID=66f5f0c653114955b1d0762f2800c750
CollectMode=inactive
hjelev commented 2 months ago

your service file don't look OK. It should look like the example https://github.com/hjelev/rpi-mqtt-monitor/blob/master/rpi-mqtt-monitor.service with couple of values/paths changed. I would recommend you to reinstall the script and allow it to reset your service file.

WarC0zes commented 2 months ago

I would recommend you to reinstall the script and allow it to reset your service file.

I reinstalled the script and reset the service. After installation, I restarted the service and it worked.

image

Thanks for your help. 👍

WarC0zes commented 2 months ago

Hi @hjelev, The new update is displayed in the update entity. But it's impossible to install it from HA, I click on install and nothing happens ( no errors in log ). I had to update manually. Have you tried updating from HA?