After watching @DrZzs
and doing it I could tasmota to lean the rf codes It has 4 speeds
high med low off
so I created a script for each one and MQTT sensor which keep track of the Speed
the two Sensor
- platform: mqtt
name: "Lounge Fan Status"
state_topic: "home/lounge-fan"
- platform: mqtt
name: "Lounge Fan cmnd"
state_topic: "home/lounge/fan/cmnd/FanSpeed"
now the Scripts
lounge_fan_3:
alias: lounge fan Speed 3
sequence:
- service: mqtt.publish
data:
topic: "cmnd/RF_Bridge_raw/Backlog"
payload: "RFRAW AA B0 1E 03 08 017C 02E4 2620 28090909181818180909090909090909180909090909 55 RFRAW 0"
- service: mqtt.publish
data:
topic: "home/lounge-fan"
payload: "3"
- service: mqtt.publish
data:
topic: "home/lounge/fan/cmnd/FanSpeed"
payload: "on"
mode: single
lounge_fan_2:
alias: lounge fan Speed 2
sequence:
- service: mqtt.publish
data:
topic: "cmnd/RF_Bridge_raw/Backlog"
payload: "RFRAW AA B0 1E 03 08 0172 02E4 2620 28090909181818180909090909090918090909090918 55 RFRAW 0"
- service: mqtt.publish
data:
topic: "home/lounge-fan"
payload: "2"
- service: mqtt.publish
data:
topic: "home/lounge/fan/cmnd/FanSpeed"
payload: "on"
mode: single
lounge_fan_1:
alias: lounge fan Speed 1
sequence:
- service: mqtt.publish
data:
topic: "cmnd/RF_Bridge_raw/Backlog"
payload: "RFRAW AA B0 1E 03 08 0172 02E4 2620 28090909181818180909090909090918180909091809 55 RFRAW 0"
- service: mqtt.publish
data:
topic: "home/lounge-fan"
payload: "1"
- service: mqtt.publish
data:
topic: "home/lounge/fan/cmnd/FanSpeed"
payload: "on"
mode: single
lounge_fan_0:
alias: lounge fan Speed 0
sequence:
- service: mqtt.publish
data:
topic: "cmnd/RF_Bridge_raw/Backlog"
payload: "RFRAW AA B0 1E 03 08 017C 02E4 2620 28090909181818180909090909090909090918181818 55 RFRAW 0"
- service: mqtt.publish
data:
topic: "home/lounge-fan"
payload: "0"
- service: mqtt.publish
data:
topic: "home/lounge/fan/cmnd/FanSpeed"
payload: "off"
mode: single
NOTE the script name and the payload of the MQTT
now the fan controler bit
- platform: mqtt
name: "Lounge Fan"
state_topic: "home/lounge/fan/cmnd/FanSpeed"
command_topic: "home/lounge/fan/cmnd/FanSpeed"
speed_state_topic: "home/lounge-fan"
speed_command_topic: "home/lounge-fan"
payload_on: "on"
payload_off: "off"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
speeds:
- low
- medium
- high
now the bit that join them
I want the right script to run when I select the speed
so could used the new choose option (still getting head around it)
- id: b12c44a8-d707-4892-9f75-c84c6927dab4
alias: Lounge Fan Control
initial_state: true
trigger:
- entity_id: sensor.lounge_fan_status
platform: state
action:
- data_template:
entity_id: script.lounge_fan_{{ trigger.to_state.state }}
service: script.turn_on
now the tidy ups
- id: c9fe33f8-07a1-4bf3-9bd5-2fd144d4dcd6
alias: Lounge Fan Status right
trigger:
- entity_id: sensor.lounge_fan_cmnd
platform: state
to: 'off'
action:
- service: mqtt.publish
data:
topic: "home/lounge-fan"
payload: 0
as I have all the right bits to make a switch so
- platform: template
switches:
lounge_fan:
icon_template: mdi:fan
friendly_name: Lounge Fan
value_template: '{{ is_state("sensor.lounge_fan_cmnd", "on") }}'
turn_on:
service: script.turn_on
data:
entity_id: script.lounge_fan_1
turn_off:
service: script.turn_on
data:
entity_id: script.lounge_fan_0
putting all together
here the code
cards:
- cards:
- entity: climate.lounge_fan
name: Lounge Fan
type: 'custom:simple-thermostat'
step_layout: row
control:
_headings: false
type: horizontal-stack
- cards: null
entities:
- entity: fan.lounge_fan
type: 'custom:fan-control-entity-row'
name: Fan
- entity: switch.lounge_fan
type: entities
- cards:
- align_state: center
entities:
- color: '#11A579'
entity: sensor.bt_lounge_temperature
index: 0
name: Lounge
type: 'custom:mini-graph-card'
type: horizontal-stack
type: 'custom:vertical-stack-in-card'
cant take credit for the lovelace found that in here.