Skip to content

Instantly share code, notes, and snippets.

@frauhottelmann
Last active April 23, 2024 18:06
Show Gist options
  • Save frauhottelmann/1b45b8fa13e506a17c4ea70380e46949 to your computer and use it in GitHub Desktop.
Save frauhottelmann/1b45b8fa13e506a17c4ea70380e46949 to your computer and use it in GitHub Desktop.
blueprint:
name: "Tasmota Discovery: Duux DXCF10 / DXCF12"
description: |
Set up a Duux DXCF10 / DXCF12 running Tasmota in Home Assistant. See device template page for additional information: [Duux DXCF12](https://templates.blakadder.com/duux_DXCF12.html).
**Apply template:**
```
template {"NAME":"Duux DXCF12","GPIO":[0,0,0,0,0,0,0,0,0,2304,0,2272,0,0],"FLAG":0,"BASE":54,"CMND":"TuyaMCU 61,2 | TuyaMCU 62,3 | TuyaMCU 12,4 | TuyaMCU 13,5 | TuyaMCU 64,6"}
```
**Requires rules configured in Tasmota!**
```
rule3
on tuyareceived#dptype4id2 do publish %topic%/mode %value% endon
on tuyareceived#dptype4id3 do publish %topic%/speed %value% endon
on tuyareceived#dptype4id6 do publish %topic%/timer %value% endon
rule3 1
```
<small>Built for Home Assistant 2022.8+</small>
domain: automation
input:
tasmota_device:
name: "Tasmota Device"
description: "Select the Tasmota device"
selector:
device:
integration: tasmota
manufacturer: "Tasmota"
topic:
name: Tasmota MQTT Topic
description: |
Found in the web UI "Information" menu under "MQTT Topic" or with `Topic` command
selector:
text:
mode: single
max_exceeded: silent
variables:
device_id: !input tasmota_device
topic: !input topic
connections: "{{ device_attr(device_id, 'connections') }}"
name: "{{ device_attr(device_id, 'name') if device_attr(device_id, 'name_by_user') == None else device_attr(device_id, 'name_by_user') }}"
macaddr: >-
{%- for i in device_attr(device_id, 'connections') -%}
{{ i[1].replace(":", "") }}
{% endfor %}
payload_mode: >-
{{
'{
"name":"' ~ name ~ ' Mode",
"state_topic":"' ~ topic ~ '/mode",
"icon":"hass:fan",
"options":["Natural Mode","Sleep Mode","Manual Mode"],
"value_template":"{%- set val = { \'1\':\'Natural Mode\', \'2\':\'Sleep Mode\', \'0\':\'Manual Mode\' } -%}{{ val[value] | default(\'Manual Mode\', true) }}",
"command_topic":"cmnd/' ~ topic ~ '/backlog0",
"command_template":"{%- set val = { \'Natural Mode\':\'1\', \'Sleep Mode\':\'2\', \'Manual Mode\':\'0\' } -%} tuyasend4 2,{{ val[value] }}",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ 'mode",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_error: >-
{{
'{
"name":"' ~ name ~ ' Error",
"icon":"hass:fan-alert",
"entity_category":"diagnostic",
"state_topic":"' ~ topic ~ '/error",
"value_template":"{%- set val = { \'0X00\':\'No Error\', \'0X01\':\'Kettle empty\', \'0X04\':\'Kettle overheated\'} -%}{{ val[value] | default(\'\', true) }}",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_error",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_speed: >-
{{
'{
"name":"' ~ name ~ ' Fan Speed",
"icon":"hass:fan",
"min":0,
"max":25,
"state_topic":"' ~ topic ~ '/speed",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend4",
"command_template":"3,{{ value }}",
"mode":"box",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ '_speed",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
payload_timer: >-
{{
'{
"name":"' ~ name ~ ' Off Timer",
"icon":"hass:fan",
"device_class":"duration",
"unit_of_measurement":"h",
"min":0,
"max":12,
"state_topic":"' ~ topic ~ '/timer",
"command_topic":"cmnd/' ~ topic ~ '/tuyasend4",
"command_template":"6,{{ value }}",
"mode":"box",
"avty_t":"tele/' ~ topic ~ '/LWT",
"pl_avail":"Online",
"pl_not_avail":"Offline",
"uniq_id":"' ~ macaddr ~ 'timer",
"dev":{"cns":[["mac","' ~ macaddr ~ '"]]}
}'
}}
trigger_variables:
topic: !input topic
trigger:
- platform: homeassistant
event: start
- platform: mqtt
topic: '{{ "tele/" ~ topic ~ "/LWT" }}'
payload: "Online"
action:
- service: mqtt.publish
data:
topic: "homeassistant/select/{{ macaddr }}/mode/config"
retain: true
payload: "{{ payload_mode }}"
- service: mqtt.publish
data:
topic: "homeassistant/sensor/{{ macaddr }}/error/config"
retain: true
payload: "{{ payload_error }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/speed/config"
retain: true
payload: "{{ payload_speed }}"
- service: mqtt.publish
data:
topic: "homeassistant/number/{{ macaddr }}/timer/config"
retain: true
payload: "{{ payload_timer }}"
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: mqtt.publish
data:
topic: "cmnd/{{ topic }}/tuyasend8"
payload: ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment