I’m new to HA, however I’ve got it up and running and triggering relays on my Pi. What I can’t work out how to do is, have a momentary input NO going NC on a gpio input, to toggle the state of a output pin, and subsequently update the dashboard with the status change of the switch/output.
If somebody could attach some sample code that would be a great help, I have been looking for hours for a suitable answer but can’t find anything.
Also on the pi, if I run gpio readall I get unknown command (I used the all in one installer of HA). Do I need to install something additional, wiring pi or other?..
Thanks I will look into it. Yes just a push button as such.
Am I right in thinking the reference switch.toggle is related to the content of switch.yaml? Is this how things are referenced? As I say I’m very new to this, next step is temp sensors, which will probably be another minefield:see_no_evil:.
switch.toggle is the service linked to the action. You also have a switch.turn_on and switch.turn_off.
So you could have one pushbutton to only switch things on, and another to only switch things off, or toggle as per the code example.
The entity_id: in this case would be the reference.
switch.name_of_the_thing
sensor.name_of_the_thing
Usually everything lives in configuration.yaml, but you can split it up into separate files.
You’ll just have to tell hass via configuration.yaml to include them and where they are.
I had a single pushbutton configured and tested to trigger a pi GPIO output. I have now done what i think is correct in the configuration file (i havent got around to splitting automation file as yet). However when pushing the buttons they may work once but then not again ie, they will switch the ligh on int he living room but when pressed again it wont go off. Could you somebody check the following code please?
Not sure if it is related to cable distances/interference or if its the code itself.
I have normally open going closed momentary switches (push buttons) that are connected to the codes respective GPIOs. I have also tried with external pull up resistors 4.7k and 10k and still seeing the same results. When monitoring the sensor status on the HA status page, they do not always change state and when they do change state it doesnt always switch the output.