I have a switch (=toggle switch) that can be turned on , but the state won’t work.
When I put in safari browser http://192.168.0.141:8080/#entry/0/4 I can see that the light is on or off like this: when the light is on it shows colored in grey and off is white.
Any idea how to fix it?
I’ve been searching for some time to resolve it…
I feel your pain. I’ve created a command-line PIR occupancy sensor. Documentation says its state can be “On” or “Off”. My sensor returns precisely “On” or “Off”, yet Home Assistant doesn’t ever see any change in the sensor. FYI, I’ve tried the values “ON” and “on” as well as “True” and “true” and those did not change anything. With a numeric value, it’s simple. With a Boolean who knows?
I added a space after the left-angle-bracket/less-than symbols so that it displays properly here. I’d guess I need to update my value_template line to include the html and /html tags? OR simply drop all the HTML encoding from the sensor. Which seems to work just fine for my two RPi/Python sensors that return decimal values for Lux illumination sensors.
Thank you, @finity. I wound up dropping the HTML tags and now the sensor is displaying ‘On’ or ‘Off’ without them, although the value is still not translating into HA. FYI, this is the updated output of the curl command:
fred@hassio:~$ curl http://192.168.1.37/
On
fred@hassio:~$
try just creating a “sensor” instead of a “binary sensor”.
It should return the same “On” or “Off” state and then you can use that state in any automations as is and you don’t have to worry about it not being in the exact correct format for a binary sensor.
If the output on the HA console is the same, how should HA determine the state of your light?
That would be AI if it can.
You need something other for the state command, maybe a Scrape Sensor, or something.
@VDRainer
Do you mean that the sensor can scrape for the negative color to see if the light is on?
I will give it a try but any idea how to describe the value_template in the scrape sensor ? Something like:
Thanks for the support.
Sorry, i have absolutely no clue about scraping websites.
Maybe post the whole html in another topic and ask for help.
Which kind of lights are these? Isn’t the any other query to get the state?
No need for sorry,
These are lights from my home domotica system that I can acces true a webserver where I have to log in.
I spend a lot off time to get them work into HA with curl (= because of the credentials needed to acces the webserver). So I can control all the lights with HA but without getting the states of the switches I can make no automations and the other cool stuff that HA is made for
But my curl command in HA to turn on a light have a number in comparisation for the above pic like:
For example action/6640 is my light called Led venster like you can see in the screenshot above
Reviewing the ‘dev-state’ (’< >’ icon on the sidebar) I realized the final source of my issue. After removing the HTML, after latching the occupancy status returned for X minutes, it still was not firing the automation. The issue was the value in my automation.yaml file. I used sentence-case ‘On’ and HA expects ‘on’ in lowercase. I’d have thought HA would force lowercase before comparing, but oh well, I’ve learned yet another feature of HA.
That’s why I advised to create a sensor instead of a binary sensor since the results of a sensor can be anything but the binary sensor needs a specific on/off state.