2021.03 and tasmotized Sonoff IFan03 - lots of errors in log and fan unavailable

Hi Guys

I have updated to the latest Home-Assistant 2021.03 today. I am running HA in a docker container.

With this latest update my tasmotized iFan03 is now showing as unavailable. Relevant log shows:

2021-03-05 05:47:47 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'tele/fan1/LWT': 'Online'
 Traceback (most recent call last):
   File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 32, in wrapper
     msg_callback(msg)
   File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 295, in availability_message_received
     self.async_write_ha_state()
   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 295, in async_write_ha_state
     self._async_write_ha_state()
   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 313, in _async_write_ha_state
     attr = self.capability_attributes
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 510, in capability_attributes
     attrs[ATTR_PRESET_MODES] = self.preset_modes
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 634, in preset_modes
     return preset_modes_from_speed_list(self.speed_list)
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 680, in preset_modes_from_speed_list
     return [
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 683, in <listcomp>
     if speed.lower() in _NOT_SPEEDS_FILTER and speed.lower() != SPEED_OFF
 AttributeError: 'bool' object has no attribute 'lower'

When I switch on the fan in the tasmota interface home assistat shows some more error messages such as:

2021-03-05 07:21:10 ERROR (MainThread) [homeassistant.util.logging] Exception in speed_received when handling msg on 'stat/fan1/RESULT': '{"FanSpeed":1}'
 Traceback (most recent call last):
   File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 32, in wrapper
     msg_callback(msg)
   File "/usr/src/homeassistant/homeassistant/components/mqtt/fan.py", line 248, in speed_received
     self.async_write_ha_state()
   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 295, in async_write_ha_state
     self._async_write_ha_state()
   File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 313, in _async_write_ha_state
     attr = self.capability_attributes
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 510, in capability_attributes
     attrs[ATTR_PRESET_MODES] = self.preset_modes
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 634, in preset_modes
     return preset_modes_from_speed_list(self.speed_list)
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 680, in preset_modes_from_speed_list
     return [
   File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 683, in <listcomp>
     if speed.lower() in _NOT_SPEEDS_FILTER and speed.lower() != SPEED_OFF
 AttributeError: 'bool' object has no attribute 'lower'

My relevant yaml for the fan integration is as follows (just in case):

fan OfficeFan:
  - platform: mqtt  
    name: "Office Fan"
    command_topic: "cmnd/fan1/FanSpeed"
    speed_command_topic: "cmnd/fan1/FanSpeed"    
    state_topic: "stat/fan1/RESULT"
    speed_state_topic: "stat/fan1/RESULT"
    state_value_template: >
      {% if value_json.FanSpeed is defined %}
        {% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %}
      {% else %}
        {% if states.fan.office_fan.state == 'off' -%}0{%- elif states.fan.office_fan.state == 'on' -%}4{%- endif %}
      {% endif %}
    speed_value_template: "{{ value_json.FanSpeed }}"
    availability_topic: tele/fan1/LWT
    payload_off: "0"
    payload_on: "4"
    payload_low_speed: "1"
    payload_medium_speed: "2"
    payload_high_speed: "3"
    payload_available: Online
    payload_not_available: Offline
    speeds:
      - off
      - low
      - medium
      - high

After all of the above information… is there anything I can do on my end to get my fan properly working again with HA 2021.03?

For the time being I’ll revert back to the previous version.

1 Like

I use that same fan code but I haven’t updated yet. (which is one of the reasons why I never update immediately).

You should submit a bug report for the error you are getting.

What’s the best way of doing this?

Open a new issue on GitHub, here: https://github.com/home-assistant/core/issues
Maybe do a search for “fan” before submitting though, found 5 matches in last 2 days

Github issue raised:

2 Likes

@Faramir

Can I ask what HA version you are running (HA OS, supervised, core, container)?

I updated a couple of test version (one Supervised and another Container) and I’m getting different results between the two.

In the Supervised version the fans and controls still work.

But in the container version I am getting a bunch of errors for the fans and they won’t even show up as entities and I’m getting errors just like you are getting above.

I can’t see why there would be a difference between Container or supervised tho. They are supposed to be identical in the core implementations.

I’ll add my observations to the bug report.

finity - thanks for all your work on the fan-control-entity-row and getting onto this issue so quickly.

This is exactly what I am also seeing.

Proxmox VM
Supervisor-2021.03.4
Host - Home Assistant OS 5.12
Latest version of fan-control-entity-row.js

For now I have rolled back to core-2021.2.3 and all is working again

When I installed core-2021.3:

  • SonoffFan device is created
  • No Fan entity being created when updated to 2021.3
  • Switch entities for Light, Speed 1, Speed 2, Speed 3 are all created but no actual fan.study_fan.
  • automations utilising switches work
  • automations utilising fan entity do not

HA log states

  • setup fof fan platform mqtt is taking over 10 seconds - Fan (warning)
  • error adding entities for domain fan with platform mqtt - Fan (error)

Would be happy to test anything you need or look anything up - I have created VM backups of both versions and so and able to switch and rollback between versions fairly quickly to test anything.

1 Like

I’m not sure if there is anything I can do until HA itself figures out why we are getting these errors.

1 Like

I am running the plain docker image provided by home assistant. I haven’t got supersised.
(image: homeassistant/home-assistant:stable in docker compose gave me trouble)

Erik has responded to the Github issue and provided changes to the my fan definition as above. Apparently we should put quotes around all string values in yaml files as otherwise it might get interpreted as a boolean false.

So I have changed my yaml file as per below (added a bunch of quotes).
This version of my fan configuration is working for me with Home Assistant core 2021.3.1

fan OfficeFan:
  - platform: mqtt  
    name: "Office Fan"
    command_topic: "cmnd/fan1/FanSpeed"
    speed_command_topic: "cmnd/fan1/FanSpeed"    
    state_topic: "stat/fan1/RESULT"
    speed_state_topic: "stat/fan1/RESULT"
    state_value_template: >
      {% if value_json.FanSpeed is defined %}
        {% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %}
      {% else %}
        {% if states.fan.office_fan.state == 'off' -%}0{%- elif states.fan.office_fan.state == 'on' -%}4{%- endif %}
      {% endif %}
    speed_value_template: "{{ value_json.FanSpeed }}"
    availability_topic: tele/fan1/LWT
    payload_off: "0"
    payload_on: "4"
    payload_low_speed: "1"
    payload_medium_speed: "2"
    payload_high_speed: "3"
    payload_available: "Online"
    payload_not_available: "Offline"
    speeds:
      - "off"
      - "low"
      - "medium"
      - "high"
5 Likes

Confirm that after updating configuration to include “” this is also working for me with 2021.3.1

Thank you all for speedy reply.

yes, that is the difference between my two instances. the one that worked had quotes around “off” and the other one didn’t.

I’m not sure why the other one didn’t have quotes around the “off” speed tho because my production install has quotes. must have been a brain fart in my test instance. :man_shrugging:

But there are no quotes around any of the other speeds. It doesn’t hurt anything but it isn’t necessary.

mine was also missing the quotes on the speeds thanks for finding the solution

fixed for me as well.

This is why I love this community!
Thanks for the info, mine is now working again too!

1 Like

Here is a thread I just started for info on using the fans with the new controls:

The problem is because the fan speeds listed are deprecated in home assistant since March 2021.

   speeds:
      - "off"
      - "low"
      - "medium"
      - "high"

Now home assistant would like percentages instead. I am not sure how to fix this unless you change the speed options to 0 1 2 3 4. I would like to continue to say low - medium - high to google assistant but I think this isn’t allowed anymore. The only consequence I get from not removing the speeds low-medium-high is that I get errors in my home assistant logs and I can no longer reboot from the webif. The Cofiguration>Server Controls> Check Configuration button no longer works and that is what kills the reboot ability. The fan and google assistant still work as before, just home assistant complains and won’t reboot from the webif.
UPDATE: after putting the quotes on the speeds as noted in the solution, after some time the Check Configuration button did start working again. It just was not instant after a reboot.

1 Like

For anyone in this thread that would like to see the old speed lists reinstated…

I’ve requested that the old speed list options should be kept and I’ve had a suggestion from a dev that if a FR gets enough votes they would implement it.

Here is the FR. Please go there and vote it up.

1 Like