ESPEasy Security System with HA

I setup and configured ESPEasy on NodeMCU ESP8266. So far, everything looks good. At this time I am testing. I have 7 PINs connected to 7 doors and windows sensors. Open, close doors and windows works well.

The problem that I have is when I reboot RPi or restart HA. All doors and windows are opened at this time, but after reboot, HA shows that five of them are closed and two are opened. When I close and open whatever is connected to the sensor, everything switches to correct settings, but I have to open/close first.

Can someone help with this?

This is my configuration.yaml file:

binary_sensor:
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO0/Status"
    name: "MCU1_GPIO0"
    payload_on: 1
    payload_off: 0
    device_class: opening
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO2/Status"
    name: "MCU1_GPIO2"
    payload_on: 1
    payload_off: 0
    device_class: opening
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO4/Status"
    name: "MCU1_GPIO4"
    payload_on: 1
    payload_off: 0
    device_class: opening
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO5/Status"
    name: "MCU1_GPIO5"
    payload_on: 1
    payload_off: 0
    device_class: opening
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO12/Status"
    name: "MCU1_GPIO12"
    payload_on: 1
    payload_off: 0
    device_class: opening
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO13/Status"
    name: "MCU1_GPIO13"
    payload_on: 1
    payload_off: 0
    device_class: opening
  - platform: mqtt
    state_topic: "NodeMCU1/GPIO14/Status"
    name: "MCU1_GPIO14"
    payload_on: 1
    payload_off: 0
    device_class: opening

If the state after reboot is random, I suggest that you set up your ESPEasy to publish MQTT messages with the retain flag set. This will cause the broker to re-send the state of the sensors when HA reconnects.

I haven’t used ESPEasy, but I understand its a check box somewhere.

Yeah, it’s under Tools > Advanced > MQTT Retain Msg :slight_smile:

Looks like it worked. Thank you guys.