Hi all. I recently decided to take the leap from Domoticz and espeasy to home assistant.
I’m struggling for a while now on a coding ussue. Say i have a microSwitch to read the state of a door or window and output to a led the state. Closed is on and open is off.
I get that done with:
> on_state:
> - switch.toggle: mcp23017_pin_b0
Problem is when Door or window is clossed at boot, the status led works in reverse.
Closed is off and open is on.
On espeasy i had a rule that checked the pin state on startup and changed the output to the status leds
from there.
Rule from espeasy…
> on System#Boot do
> monitor,mcp,17
> endon
>
> on DeurVoordeur#Switch do
> if [DeurVoordeur#Switch]=1
> mcpgpio,5,0
> else
> [DeurVoordeur#Switch]=0
> mcpgpio,5,1
> endif
> endon
what i have in ESPHome…
> i2c:
> sda: 4
> scl: 5
> scan: True
> frequency: 800kHz
>
> mcp23017:
> - id: 'mcp23017_1'
> address: 0x21
>
> # Individual outputs
> switch:
> - platform: gpio
> pin:
> mcp23xxx: mcp23017_1
> number: 8
> mode:
> output: true
> inverted: True
> id: mcp23017_pin_b0
>
> # Individual inputs
> binary_sensor:
> - platform: gpio
> pin:
> mcp23xxx: mcp23017_1
> number: 7
> inverted: true
> mode:
> input: true
> pullup: true
> name: "Living Room Window"
> device_class: window
> filters:
> - delayed_on: 10ms
> on_state:
> - switch.toggle: mcp23017_pin_b0
I have tried allot of different ways, but can’t get it to work the right way.
Any push in the right way will be appreciated.
Thanks
Nuke