adrianByv / home-assistant-custom-components-switch-humidifier

Home Assistant custom component Switch Humidifier Platform
MIT License
18 stars 7 forks source link

AttributeError: 'NoneType' object has no attribute 'state' #12

Open pristis opened 9 months ago

pristis commented 9 months ago

Hello, I can't turn on or off the switch via humidifier entity. There is the log if home assistant:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/config/custom_components/switch_humidifier/humidifier.py", line 208, in _state_changed
    if not new_state is None and not new_state.state == 'unknown' and not new_state.state == 'unavailable' and not old_state.state == new_state.state:
                                                                                                                   ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'

There is my config code:

humidifier: 
  - platform: switch_humidifier
    name: Humidifier
    switch_id: switch.sonoff_10017a2176
    sensor_id: sensor.temp1_humidity
    type: humidifier
    start_delta: 0.2
    stop_delta: 0.2

Can you help me, please? Thanks!