I have a fan that is controlled by the Bond Bridge integration. This ONLY gives me the ability to toggle the fan by sending the “on” command. I have also recently plugged it into an energy monitoring plug and have determined that for the most part anything above 2w is “on”.
First I tried creating a “status” helper that would be “on” if the current was above 2 and “off” it is was below. Then I created a toggle helper switch that would take an “off” command and then compare it to the status helper. If it was already off, then it wouldn’t do anything, but if it was on, then the toggle command would be sent. (and vice versa, of course). It actually worked. Problem is, this toggle helper switch doesn’t show up as a switch that I control through Alexa. SO - I have been trying to figure out templates, thinking this was a first good scenario. I’ve read all the docs, and I just can’t seem to figure out how to do it.
switch:
- platform: template
switches:
bedside_fan:
friendly_name: "Bedside Fan Switch"
unique_id: "bedside_fan_switch"
value_template: "{{ is_state('input_boolean.bedside_fan_status', 'on') }}"
turn_on:
service: switch.turn_on
data:
entity_id: fan.bedside_fan
turn_off:
service: switch.turn_on
data:
entity_id: fan.bedside_fan'
Here is the automation that currently successfully creates the helper toggle that knows whether the fan is on or off:
'alias: Bedside Fan Status Control
description: Controls the Bedside Fan helper status based on energy consumption
trigger:
- platform: state
entity_id:
- sensor.bedside_fan_energy_monitor_current_consumption
condition: []
action:
- if:
- type: is_power
condition: device
device_id: 86b0a18c58a881fd13633541fa4d1883
entity_id: sensor.bedside_fan_energy_monitor_current_consumption
domain: sensor
above: 2
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.bedside_fan_status
- if:
- type: is_power
condition: device
device_id: 86b0a18c58a881fd13633541fa4d1883
entity_id: sensor.bedside_fan_energy_monitor_current_consumption
domain: sensor
below: 2
then:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.bedside_fan_status
mode: single
The fan.bedside_fan only has an “on” command and that toggles the fan. Ultimately I want this switch template to function the way my toggle helper did. Sync with the status helper that is always monitoring the voltage, so that when a command is sent, it will react according to the status (as opposed to, say, thinking it’s turning off the fan when it’s already off, thus turning it on).
I know this is probably a “roll your eyes” kind of question. it’s always my first attempt that I feel stupid, but I think once I wrap my head around this one I’ll be able to continue to learn more. Could someone help me build this first template? I would be EVER so grateful! Ultimately, I want to have created something that I can control from Alexa (some kind of switch that Alexa will recognize as an actual switch, which the toggle helpers do not seem to!?)
Thank you!