Hello everybody! I want to introduce the custom component which extends the basic functionality of the mqtt switch with following properties:
payload_template_on
payload_template_off
example configuration.yaml:
switch:
- platform: mqtt_template
name: laundry-fan
state_topic: "home/bathroom/switch/laundry-fan/state"
command_topic: "home/bathroom/switch/laundry-fan"
payload_template_on: '{"action":"hold","duration": {{(states.input_number.fan_duration.state
| int)*1000}}}'
payload_off: '{"action":"off"}'
state_on: 1
state_off: 0
the easiest way to install this add in hacs custom repository:
https://github.com/lukich48/hass_mqtt_template_switch
or just copy the folder in custom_components.
UPD: from now it is included in HACS repository
I get rid of a lot of triggering automations and wish you’ll too