Skip to content

Instantly share code, notes, and snippets.

@ayavilevich
Created October 13, 2020 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayavilevich/2ca13ecc5653447f22a87c34a59fc27a to your computer and use it in GitHub Desktop.
Save ayavilevich/2ca13ecc5653447f22a87c34a59fc27a to your computer and use it in GitHub Desktop.
Home assistant configuration for integration with RF based smoke detectors. Full article is in my blog.
binary_sensor:
- platform: mqtt
name: "Room1 Smoke Detector"
payload_on: "0x111111"
payload_off: "0x111111off"
device_class: smoke
state_topic: "tele/tasmota_rf/RESULT"
value_template: '{{ value_json.RfReceived.Data }}'
- platform: mqtt
name: "Room2 Smoke Detector"
payload_on: "0x222222"
payload_off: "0x222222off"
device_class: smoke
state_topic: "tele/tasmota_rf/RESULT"
value_template: '{{ value_json.RfReceived.Data }}'
- platform: mqtt
name: "Test Smoke Detector"
payload_on: "0x555555"
payload_off: "0x555555off"
device_class: smoke
state_topic: "tele/tasmota_rf/RESULT"
value_template: '{{ value_json.RfReceived.Data }}'
timer:
room1_smoke_detector:
duration: '00:00:05'
room2_smoke_detector:
duration: '00:00:05'
test_smoke_detector:
duration: '00:00:05'
test_smoke_detector_check:
duration: '00:00:04'
automation:
# room1
- alias: Turn on room1 smoke sensor timer
trigger:
platform: mqtt
topic: "tele/tasmota_rf/RESULT"
condition:
condition: template
value_template: "{{ trigger.payload_json['RfReceived']['Data'] == '0x111111' }}"
action:
service: timer.start
entity_id: timer.room1_smoke_detector
- alias: Turn off room1 smoke sensor
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.room1_smoke_detector
action:
service: mqtt.publish
data:
topic: "tele/tasmota_rf/RESULT"
payload: '{"RfReceived":{"Data":"0x111111off"}}'
retain: "true"
- alias: Notify about room1 smoke detector
trigger:
- entity_id: binary_sensor.room1_smoke_detector
from: 'off'
platform: state
to: 'on'
action:
- service: persistent_notification.create
data_template:
title: Smoke detected
message: "{{ trigger.entity_id }}"
# - service: notify.mobile_app_PHONE
# data_template:
# title: Smoke detected
# message: "{{ trigger.entity_id }}"
# room2 room
- alias: Turn on room2 room smoke sensor timer
trigger:
platform: mqtt
topic: "tele/tasmota_rf/RESULT"
condition:
condition: template
value_template: "{{ trigger.payload_json['RfReceived']['Data'] == '0x222222' }}"
action:
service: timer.start
entity_id: timer.room2_smoke_detector
- alias: Turn off room2 room smoke sensor
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.room2_smoke_detector
action:
service: mqtt.publish
data:
topic: "tele/tasmota_rf/RESULT"
payload: '{"RfReceived":{"Data":"0x222222off"}}'
retain: "true"
- alias: Notify about room2 room smoke detector
trigger:
- entity_id: binary_sensor.room2_room_smoke_detector
from: 'off'
platform: state
to: 'on'
action:
- service: persistent_notification.create
data_template:
title: Smoke detected
message: "{{ trigger.entity_id }}"
# - service: notify.mobile_app_PHONE
# data_template:
# title: Smoke detected
# message: "{{ trigger.entity_id }}"
# test sensor
- alias: Turn on test smoke sensor timer
trigger:
platform: mqtt
topic: "tele/tasmota_rf/RESULT"
condition:
condition: template
value_template: "{{ trigger.payload_json['RfReceived']['Data'] == '0x555555' }}"
action:
service: timer.start
entity_id: timer.test_smoke_detector
- alias: Turn off test smoke sensor
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.test_smoke_detector
action:
service: mqtt.publish
data:
topic: "tele/tasmota_rf/RESULT"
payload: '{"RfReceived":{"Data":"0x555555off"}}'
retain: "true"
- alias: Check if test smoke detector works
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.test_smoke_detector_check
condition:
- condition: state
entity_id: binary_sensor.test_smoke_detector
state: 'off'
action:
- service: persistent_notification.create
data_template:
title: RF Smoke detector check
message: "FAILED"
# - service: notify.mobile_app_PHONE
# data_template:
# title: RF Smoke detector check
# message: "FAILED"
- alias: Run RF test check
trigger:
platform: time_pattern
minutes: 15
seconds: 0
action:
- service: script.rf_test
script:
rf_test:
sequence:
- service: timer.start
entity_id: timer.test_smoke_detector_check
- service: mqtt.publish
data:
topic: 'cmnd/tasmota_rf_test/RfSend'
payload: '0x555555'
- delay:
seconds: 1 # wait a bit
- service: mqtt.publish
data:
topic: 'cmnd/tasmota_rf_test/RfSend'
payload: '0x555555'
- delay:
seconds: 1 # wait a bit
- service: mqtt.publish
data:
topic: 'cmnd/tasmota_rf_test/RfSend'
payload: '0x555555'
- delay:
seconds: 1 # wait a bit
- service: mqtt.publish
data:
topic: 'cmnd/tasmota_rf_test/RfSend'
payload: '0x555555'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment