Commandline sensor, reload all or force update

I have 2 commandline sensors. These sensors poll my inverter. My inverter goes offline during the hours there is no sun. It comes back online when the sun starts shining.

When my HA instance is up and running and keeps being so there is no issue. The following morning the sensors start picking up the cycle. But when HA goes down (for a reboot / reload or update) the following morning the sensors only start picking up the values after reloading commandline sensors.

Now i can find a lot of reloading stuff, but not the commandline sensors. There is an button for it in the Development Tools.

My sensor is configured as follows:

- sensor:
    command: curl -s -u user:pass http://192.168.1.15/status.html | grep -E "\webdata_now_p(\s|$)" | cut -d'"' -f 2
    name: solarmanlocal_solar_current
    unit_of_measurement: "W"
    device_class: power
    scan_interval: 15
    unique_id: solarmanlocal_solar_current

A few possible solutions I can think of:

  • Generic way of reloading commandline when sun rises or when inverter is back online (PING)
  • New method of polling or sensor which doesn’t break if the inverter is offline and HA is being rebooted.

Use a scrape sensor instead?

Thanks for pointing this possibilikty out.

I’ve just created the new scrape sensor and have to see what happens tomorrow morning.

- resource: http://192.168.1.15/status.html
  scan_interval: 600
  authentication: basic
  username: user
  password: pass
  sensor:
    name: SofarSolar Totaal
    unique_id: sofarsolar_totaal
    select: "script"
    index: 1
    value_template: "{{ (( value.split(';')[7] ) | replace ('var webdata_total_e = ','') |replace('\"', '')|float  ) }}"
    unit_of_measurement: "kWh"
    state_class: "total_increasing"
    device_class: "Energy"

There is a custom component for Solarman inverters, not sure if it will work with yours ?

Yes, used that for a while, but it often got broken between updates and eventually I couldn’t get it working anymore. I then switched to the commandline sensors thinkig it was the golden egg.

I can have look at it again. Thanks for pointing out!


installed, but doens’t work for me. All entities remain unknown while having selected the correct template.

1 Like