Skip to content

Instantly share code, notes, and snippets.

@seamus65
Last active June 9, 2023 20:53
Show Gist options
  • Save seamus65/f239a7c981ab346e73a031be5c487d2c to your computer and use it in GitHub Desktop.
Save seamus65/f239a7c981ab346e73a031be5c487d2c to your computer and use it in GitHub Desktop.
blueprint:
name: FITHomes State change to MQTT
description: "FITHomes state change to MQTT.
Multiple sensor selection possible"
domain: automation
input:
sensors:
name: Sensors
description: Sensors
selector:
entity:
multiple: true
source_url: https://gist.github.com/seamus65/f239a7c981ab346e73a031be5c487d2c
mode: parallel
max: 10
trigger:
- platform: state
entity_id: !input "sensors"
condition: []
action:
- variables:
entity_id: "{{ trigger.entity_id }}"
area_id: "{{ area_id(trigger.entity_id) }}"
area_name: "{{ area_name(trigger.entity_id) }}"
state: "{{ trigger.to_state.state }}"
event_type: "{{ trigger.to_state.attributes.device_class }}"
timestamp: "{{ trigger.to_state.last_changed }}"
- service: mqtt.publish
data:
qos: "0"
retain: true
topic: homeassistant/state_changed
payload: >
{
"entity_id": "{{ entity_id }}",
"area_id": "{{ area_id }}",
"area_name": "{{ area_name }}",
"state": "{{ state }}",
"event_type": "{{ event_type }}",
"timestamp": "{{ timestamp }}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment