Hey!
I’ve spent the last 24h getting acquainted with HASS and it’s amazing. I’m still doing my baby steps but I love it already - just wanted to start off with a huge thank you
I have a Xiaomi Standing Fan 3, and I use HACS with GitHub - syssi/xiaomi_fan: Xiaomi Mi Smart Fan integration for Home Assistant to control it. Unfortunately, it does not seem to have any toggleable presets, so I have to create these myself. Luckily it does poll the various attributes so I don’t have to resort to input booleans at this stage.
In the process of automating this as a card, I’ve run into several issues:
- The WebUI complains about a plethora of missing keys in the YAML configuration:
Configuration errors detected:
Required key "entities.0.tap_action.url_path" is missing.
Required key "entities.0.tap_action.navigation_path" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.name" is missing.
Required key "entities.0.tap_action.url_path" is missing.
Required key "entities.0.tap_action.navigation_path" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.view" is missing.
Required key "entities.0.view" is missing.
Required key "entities.0.view" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.conditions" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.url" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.entities" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.attribute" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.name" is missing.
Required key "entities.0.service" is missing.
Required key "entities.0.type" is missing.
Required key "entities.0.name" is missing.
Required key "entities.0.text" is missing.
Required key "entities.0.type" is missing.
which means I cannot save the card unless I input e.g. type: null
in these.
- With the following configuration, I get an error about
required key not provided
:
type: entities
entities:
- entity: fan.xiaomi_standing_fan_3
name: Oscillation
view: null
type: null
url: null
conditions: null
entities: null
attribute: null
service: null
text: null
tap_action:
url_path: null
navigation_path: null
action: call-service
service: fan.oscillate
service_template:
entity_id: fan.xiaomi_standing_fan_3
oscillating: "{{ not state_attr('fan.xiaomi_standing_fan_3', 'oscillating') }}"
I’ve found this thread, suggesting one cannot use template in Lovelace. I’ve then managed to create a script to do this toggling, but that leads me to the next point -
- With the script in place, I can create a button card that executes the script. I’d like for it to be a toggleable card (like the default entity card), so that I can see the state + execute the script as needed. I’m stuck here
EDIT: I’ve also tried defining a template switch such as this, and I get an unknown error whenever I try to toggle it. Looking at the log file, I see e.g. the following:
File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 607, in state_attributes
data[ATTR_SPEED] = self.speed
File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 457, in speed
percentage = self.percentage
File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1157, in percentage
return ordered_list_item_to_percentage(FAN_SPEEDS_1C, self._preset_mode)
File "/usr/src/homeassistant/homeassistant/util/percentage.py", line 21, in ordered_list_item_to_percentage
raise ValueError(f'The item "{item}"" is not in "{ordered_list}"')
ValueError: The item "None"" is not in "['Level 1', 'Level 2', 'Level 3']"
Switch template:
switch:
- platform: template
switches:
fan_osc:
value_template: "{{ not state_attr('fan.xiaomi_standing_fan_3', 'oscillating') }}"
turn_on:
service: fan.oscillate
target:
entity_id: fan.xiaomi_standing_fan_3
data:
entity_id: fan.xiaomi_standing_fan_3
oscillating: true
turn_off:
service: fan.oscillate
target:
entity_id: fan.xiaomi_standing_fan_3
data:
entity_id: fan.xiaomi_standing_fan_3
oscillating: false
Any help will be appreciated!