Get/set HASS states from external touch screen

Hi all,

I have HA running on a RPI3. I now have a small sensor node working on a nodeMCU. It has a DHT22 and a PIR sensor. Values are pushed via MQTT to the RPI3 which is running the MQTT server and HA. Now I also have NEXTION display from itead. I want to use it as a small control panel for each room. The idea is now to hook it up to a nodeMCU with a serial connection (also have a pi zero W). What would be the best way to get for example the state of a switch, so I can display it’s state on the nextion display. Also I would like to change the state by pressing the touch screen. What would be the best way to achieve this?

Right now I am thinking of broadcasting MQTT messages with the states and creating template switches to display the MQTT state. On/Off. But if I have to do that for each switch, seems like a lot of work. Is there an easier way to read/write to the HASS instance?

Kind regards,

Timo

Maybe the RESTApi is what you are looking for?
Get states:


Set states:

~Cheers

Hi PhyberApex,

Thanks for the input. This is exactly what I need, but; I am having issues with my HTTPS encryption. My local IP address is https://10.10.1.106:8123. If I use this in a browser, I can ignore certificate problems. The curl command does not allow it. Because the certificate was given for my dynamic DNS.

Is there a way around this?

Maybe this from manpage of curl helps?

-k, --insecure (SSL) This option explicitly allows curl to perform “insecure” SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. This makes all connections considered “insecure” fail unless -k, --insecure is used.

~Cheers

Thanks, that helped getting past my SSL issues. Now another problem pops up. GET, works perfectly (testing with HUE bulb). I retrieve a list of attributes and a state that matches what I have. If I use the POST however, and just change the state off/on, I retrieve the full JSON string with the state I entered. But visually the light does not switch. If I check the home assistant history though I see that home assistant registered an off event. Is this a hue problem? I don’t have another actuator to try with at the moment.

Probably have to directly post to the hue API. Anyway I’ll try tomorrow, it’s past midnight again :). Thanks for the help so far.

I can’t really help you out with hue as I don’t own that component / have no experience with it. But I can say that setting states via REST API POST requests works as expected.

~Cheers

Hey there, Have you finally made it? If so, please share. I got few Nextion display, and really want to use them as HASS control panels. I’ll appreciate your assistance. Thanks.