Deta Light and Fan Switch (6914HA)

Available from:
Bunnings.com.au
Bunnings.co.nz
Install method:
USB to Serial
GPIO # | Component |
---|---|
GPIO00 | Button2 |
GPIO01 | None |
GPIO02 | None |
GPIO03 | LedLinki |
GPIO04 | Relay3 |
GPIO05 | Button3 |
GPIO09 | None |
GPIO10 | None |
GPIO12 | None |
GPIO13 | Relay2 |
GPIO14 | Relay1 |
GPIO15 | Relay4 |
GPIO16 | Button1 |
FLAG | None |
Configuration (old format, will be converted to new template when applied)
{"NAME":"Deta Fan Speed and Light Controller","GPIO":[18,0,0,158,23,19,0,0,0,22,21,24,17],"FLAG":0,"BASE":18}
Decouple Buttons from Relays
SetOption73 1
Single rule to handle fan speed logic
Rule1
ON SYSTEM#Init DO Backlog var1 3; var2 1 ENDON
ON BUTTON1#State=10 DO power1 Toggle ENDON
ON BUTTON2#State=10 DO event p=%var2% ENDON
ON BUTTON3#State=10 DO event s=%var1% ENDON
ON EVENT#p>0 DO power4 ON ENDON
ON EVENT#p>0 DO power3 ON ENDON
ON EVENT#p>0 DO power2 ON ENDON
ON EVENT#p>0 DO var1 2 ENDON
ON EVENT#p>0 DO var2 0 ENDON
ON EVENT#p=0 DO power3 OFF ENDON
ON EVENT#p=0 DO power4 OFF ENDON
ON EVENT#p=0 DO power2 OFF ENDON
ON EVENT#p=0 DO var1 3 ENDON
ON EVENT#p=0 DO var2 1 ENDON
ON EVENT#s>0 DO var2 0 ENDON
ON EVENT#s=1 DO power3 OFF ENDON
ON EVENT#s=1 DO power4 OFF ENDON
ON EVENT#s=1 DO power2 ON ENDON
ON EVENT#s=1 DO var1 3 ENDON
ON EVENT#s=2 DO power3 OFF ENDON
ON EVENT#s=2 DO power4 ON ENDON
ON EVENT#s=2 DO power2 ON ENDON
ON EVENT#s=2 DO var1 1 ENDON
ON EVENT#s=3 DO power3 ON ENDON
ON EVENT#s=3 DO power4 ON ENDON
ON EVENT#s=3 DO power2 ON ENDON
ON EVENT#s=3 DO var1 2 ENDON
ON POWER2#State=0 DO power4 OFF ENDON
ON POWER2#State=0 DO power3 OFF ENDON
ON POWER2#State=0 DO var1 3 ENDON
ON POWER2#State=0 DO var2 1 ENDON
ON POWER2#State=1 DO power4 ON ENDON
ON POWER2#State=1 DO power3 ON ENDON
ON POWER2#State=1 DO var1 2 ENDON
ON POWER2#State=1 DO var2 0 ENDON
Enable rule with Rule1 1
Description:
SetOption73
Decouples the buttons and relay
The VAR1 can be thought of as “NextSpeed” and VAR2 as “Next Power”, if it makes it easier to read the code
Notes:
- Relay 1 is the main light relay controlled by button1 (the light button)
- Relay 2 is the main fan relay controlled by the button2 (the fan button)
- Relay 3 is the secondary fan relay controlled by the bottom3 (the array buttons)
- Relay 4 is the tertiary fan relay not physically connected to any buttons
Rule Logic
- Relay 3 and 4 will always turn on with Relay 2
- VAR1 is set to 3 at Initialisation and when the fan is powered off to ensure full power to fan to startup
- VAR2 is set to 1 at Initialisation to control the fan “next power state”
- Button 2 will always toggle the power to the fan (and reset state)
- Button 3 will always decrease speed one at a time 3 -> 2 -> 1 -> 3
*** HOME ASSISTANT - 2021.7 new fan layout needs different config. Old config has been deprecated and no longer works.
- Do above steps (SetOption73, Rule1)
- Add Rule: (edit the MQTT publish to suit your setup)
Rule2 ON var1#State DO Publish stat/master-bedroom/%topic%/fanspeed %value% ENDON
- Activate Rule
Rule2 1
- Home Assistant configuration.yaml
Notes on fields to change:
- name (change to your device name)
- unique_id (anything unique)
- mqtt topics: replace ‘master-bedroom/bedroomfanlightswitch’ with whatever your setup uses
fan:
- platform: mqtt
name: "Master Bedroom Fan"
unique_id: master_bedroom_fan
command_topic: "cmnd/master-bedroom/bedroomfanlightswitch/POWER2"
state_topic: "stat/master-bedroom/bedroomfanlightswitch/POWER2"
preset_mode_command_topic: "cmnd/master-bedroom/bedroomfanlightswitch/Backlog"
preset_mode_command_template: >
{% if value == 'low' %}
Event s=1
{% elif value == 'medium' %}
Event s=2
{% elif value == 'high' %}
Event s=3
{% endif %}
preset_mode_state_topic: "stat/master-bedroom/bedroomfanlightswitch/fanspeed"
preset_mode_value_template: >
{% if value == '2' %}
high
{% elif value == '1' %}
medium
{% elif value == '3' %}
low
{% endif %}
availability_topic: "tele/master-bedroom/bedroomfanlightswitch/LWT"
payload_available: "Online"
payload_not_available: "Offline"
preset_modes:
- 'low'
- 'medium'
- 'high'
Home Assistant - old fan setup (versions prior to 2021.7)
- platform: mqtt
name: Bedroom Fan
command_topic: cmnd/tasmota-7540/Backlog
state_topic: tele/tasmota-7540/STATE
state_value_template: >
{% if value_json.POWER2 == 'ON' %}
Event p=1
{% else %}
Event p=0
{% endif %}
speed_command_topic: cmnd/tasmota-7540/Backlog
speed_state_topic: tele/tasmota-7540/STATE
speed_value_template: >
{% if value_json.POWER3 == 'OFF' and value_json.POWER4 == 'OFF' %}
Event s=1
{% elif value_json.POWER3 == 'OFF' and value_json.POWER4 == 'ON' %}
Event s=2
{% elif value_json.POWER3 == 'ON' and value_json.POWER4 == 'ON' %}
Event s=3
{% endif %}
availability_topic: tele/tasmota-7540/LWT
payload_available: Online
payload_not_available: Offline
payload_low_speed: "Event s=1"
payload_medium_speed: "Event s=2"
payload_high_speed: "Event s=3"
payload_off: "Event p=0"
payload_on: "Event p=1"
speeds:
- low
- medium
- high