Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
marvin8 opened this issue Mar 4, 2021 · 7 comments
Assignees

Comments

@marvin8
Copy link

marvin8 commented Mar 4, 2021

The problem

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.

What is version of Home Assistant Core has the issue?

2021.3

What was the last working version of Home Assistant Core?

2021.2.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

MQTT Fan

Link to integration documentation on our website

https://www.home-assistant.io/integrations/fan.mqtt/

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line
@probot-home-assistant
Copy link

mqtt documentation
mqtt source
(message by IssueLinks)

@finity69x2
Copy link
Contributor

finity69x2 commented Mar 5, 2021

I'll add my observations to this as well...

I have two test installations - one is a supervised version and the other is a Container version.

I updated both to the latest HA (2021.3.1).

In the Container version I am experiencing the exact same result as the OP above - The same errors in the log and no fan entities are created for those fans.

However, in the supervised version everything works with no errors.

the fans are MQTT fans running Tasmota.

I'm not sure why the fan/MQTT integration implementation would be different between the two versions. I thought the HA core was always the same no matter which HA install method that was used.

@rob1303-hub
Copy link

I'll add my observations to this as well...

System - set-up
Proxmox VM
Supervisor-2021.03.4
Host - Home Assistant OS 5.12
Sonoff Ifan03 running tasmota (I have multiple fans - using versions 8.1/8.2/8.5/8.5.1)

Identical code for mqtt switch as Marvin8.

When installed core-2021.3:

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

HA log states

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

@emontnemery
Copy link
Contributor

Thanks for the report!

A bit off topic, but what does speed 4 do for the fan?

According to Tasmota documentation:

FanSpeed Fan speed control (iFan02/iFan03 only)
0 = turn fan OFF
1..3 = set fan speed
+ = increase fan speed
- = decrease fan speed

@emontnemery
Copy link
Contributor

emontnemery commented Mar 5, 2021

The problem is with your yaml configuration:

    speeds:
      - off # Yaml will implicitly convert this to `False`

Due to this highly confusing feature of yaml, you should make it a habit to put all strings between quotation marks:

    payload_available: "Online"
    payload_not_available: "Offline"
    speeds:
      - "off"
      - "low"
      - "medium"
      - "high"

PR tasmota/docs#662 intends to update the incorrect examples in the Tasmota docs.

@marvin8
Copy link
Author

marvin8 commented Mar 5, 2021

@emontnemery Thank you very much for taking the time to look into this and assist with my not entirely correct (:smile:) config.

I am happy to confirm that after making the changes you suggested my fan is working as usual with Home Assistant core-2021.3.1

Again, thank you!

@rob1303-hub
Copy link

@emontnemery and @marvin8.

Thank you for this.

I can also confirm all working after making the chnage.

Now to go and update to use the percentages etc.

Again. Thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants