Sennevds / system_sensors

Logging of system sensor specific for the RPI and sending them to a MQTT broker
MIT License
367 stars 113 forks source link

All sensors unavailable - error when script is run #96

Closed jsp196 closed 3 years ago

jsp196 commented 3 years ago

I get the following error when I run the python script. Below that is the config file. In Home Assistant, the sensors all populate in the MQTT integration but they all show as unavailable.

Connected to broker
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "src/system_sensors.py", line 69, in run
    self.execute(*self.args, **self.kwargs)
  File "src/system_sensors.py", line 130, in updateSensors
    payload_str = payload_str + f', "wifi_ssid": \"{get_wifi_ssid()}\"'
  File "src/system_sensors.py", line 211, in get_wifi_ssid
    "/usr/sbin/iwgetid -r",
  File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['bash', '-c', '/usr/sbin/iwgetid -r']' returned non-zero exit status 255.
`

Config File:

mqtt:
  hostname: 192.168.10.XXX
  port: 1883 #defaults to 1883
  user:
  password:
deviceName: Pi
client_id: Pi
timezone: America/Los_Angeles
update_interval: 60 #Defaults to 60
check_wifi_strength: true
check_wifi_ssid: true
check_available_updates: true
external_drives:
  Drive1: /boot/

``

jsp196 commented 3 years ago

Apparently if Wifi is off on the Pi and you poll for the SSID it breaks the script. But if you just don't poll for the SSID then it works fine.