Hi, its kind of difficult to describe it clearly in the title.
Need some help in the configuration.yaml coding.
I am using Hassio on RPi4, also using Zigbee2mqtt.
I use Tuya IR remote to control my Fan.
I created a scene in Tuya to toggle the fan power. and i can call the scene in HA to turn on/off the fan (actually just toggle power)
I mainly use Picture element to control my fan.
I have learned how to setup fake switch by using “input boolean” and “switch”
input_boolean:
living_fan_state: null
switch
- platform: template
switches:
living_fan:
value_template: "{{ is_state('input_boolean.living_fan_state', 'on') }}"
turn_on:
- service: input_boolean.turn_on
entity_id: input_boolean.living_fan_state
- service: scene.turn_on
entity_id: scene.living_fan_power
turn_off:
- service: input_boolean.turn_off
entity_id: input_boolean.living_fan_state
- service: scene.turn_on
entity_id: scene.living_fan_power
The above was working, but the fan icon doesn’t show the correct state if we manually turn on the fan. So I learn that I could also add a power monitor switch on the fan to detect the power value, thereby use this value to feedback if the fan is OFF or ON for the ICON to display accurate state, even if someone manually switch on the fan
I am using a Xiaomi Power Plug, with power monitoring.
and the detail of Xiaomi plug look like this, I know that the power will be >10W if the fan is turn on at Speed1, Speed2 >20W, Speed3>30W
So I try to use the power monitor value to reflect the correct status of my fan. So that my ICON can display state correctly. I tried the following but it doesn’t work. I know my understanding of Template is very poor, hope someone could give me guidance.
First I would just like to get my Fan Icon to display the correct ON/OFF state.
2nd, if possible, I would like my fan Icon (animated GIF) to display according to Fan speed1 or Speed2 or Speed3.
below is my non-working code:
input_boolean:
living_fan_state: null
switch
- platform: template
switches:
living_fan:
value_template: "{{ is_state('sensor.xiaomi_plug_power') > 10 }}"
turn_on:
service: scene.turn_on
data:
entity_id: scene.living_fan_power #scene to toggle my fan power
turn_off:
service: scene.turn_on
data:
entity_id: scene.living_fan_power
Appreciate your kind help in my learning journey, Thanks
I read templating in the HA documentation but I couldn’t figure out…
Thought it will be good to show my lovelace - picture element as well,
- entity: switch.living_fan
state_image:
'off': /local/fanoff.gif?v=1
'on': /local/fanon.gif?v=1
style:
left: 59%
top: 87%
transform: scale(0.7)
width: 5%
tap_action:
action: toggle
type: image