I have just installed home assistant to my RPI4. It’s not something I’m familiar with. I’m very familiar with programming, designing and troubleshooting electronics, and experimentation. None of those things seem to be useful in this software. I feel I could really use some help.
My objective:
I have designed many sensors and actors that can be accessed via HTTP requests. I wish to show sensor values and be able to trigger actors with a button push as a starting point. Maybe later I can learn how to use some logic to automate (if-this-then-that).
Here is an example to read relay status on an 8-relay board:
This is a request. Although there’s no arguments, pretend other requests may have arguments sent via GET.
http://192.168.0.xxx/RELAY_status/
The response value is standard 200 while the response content is:
XXXXXXXX\n where each of the 8 X is either 1 or 0 indicating the relay is actuated or not.
I’d like to have home assistant send out this request at the push of a button and display the response.
What I’ve done so far.
Not much. I tried TCP which didn’t work because no requests were getting sent. I then tried shell_command which worked:
shell_command:
get_relay_status: curl http://192.168.0.XXX/RELAY_status/
I created a button card that runs this:
This looks stupid. I don’t have any entity and don’t even know why an entity is needed for a button. Doesn’t it just execute an action upon pushing? Anyway. I’m watching my relay HTTP server and can confirm that this shell command was sent successfully every time I push this stupid button.
What I need yet.
I wish to display the http response somewhere. I really don’t know where to start. Document on the shell_command is very bare. So is how something can be triggered using shell_command and response being displayed. An example would be very much appreciated.
And just in case you wonder, actor, this would turn on relay 1:
shell_command:
set_relay_status: curl blah/RELAY_actuate/relay1=on
Reading a pH sensor:
read_pH: curl blah/EZO_read/?addr=99
Response would be:
200 response code with content x.xx\n
I really wish to integrate this into: if pH is say greater than x.xx, turn on relay 1. Loop every say 10 seconds so the relay turns off once pH becomes less than x.xx.