glmnet / esphome-components

1 stars 4 forks source link

In case of Arduino board restart or i2c line cut and recover ESP sending frenetically sensor state ON – OFF until restart #6

Open balazs111 opened 4 months ago

balazs111 commented 4 months ago

Hello

I wonder how can I made this a little bit more fault tolerant? I having problem when the port expander restarting or i2c line cut and recover.

After transient problem is gone it is sending frenetically sensor state ON – OFF until restart

[D][binary_sensor:036]: 'Living PIR': Sending state ON
[D][binary_sensor:036]: 'Living PIR': Sending state OFF
[D][binary_sensor:036]: 'Living PIR': Sending state ON
[D][binary_sensor:036]: 'Living PIR': Sending state OFF
[D][binary_sensor:036]: 'Living PIR': Sending state ON
[D][binary_sensor:036]: 'Living PIR': Sending state OFF
…………………………

Also I want to catch the event somehow if no connection and shut down some system until it is not recovered.

This is my test code:

external_components:
  - source: github://glmnet/esphome@ape-external-component
    components: [arduino_port_expander]

arduino_port_expander:
  id: expander1
  address: 0x08
  analog_reference: DEFAULT

binary_sensor:
  - platform: gpio
    pin:
      arduino_port_expander: expander1
      number: 9
      mode:
        input: True
        pullup: True
    name: Living PIR
    id: pir_sensor

output:
  - platform: gpio
    pin:
      arduino_port_expander: expander1
      number: 5
      mode:
        output: True
    id: tank_pump

sensor:
  - platform: arduino_port_expander
    id:  lm35_temp
    pin: A1
    name: LM35 Living room temperature
    update_interval: 10s
    filters:
      - multiply: 0.0032258064516129 # x / 1023.0 * 3.3 v

Thank you

balazs111 commented 4 months ago

With a pull up resistor i was able to correct this behavior. So i am fine. I not closing this case just because you might want to document it. Thank you