I’ve created an automation that triggers a secondary automation to send notification via notify or sms service. The second automation is like a notification service that decides whether to send an SMS or notification based on HA. So any automation that needs to send notification will call this service. I first publish to an MQTT topic (in the first automation) and then want to listen (or use that) in the second notification service but I am unable to call or listen to an MQTT service topic … any idea how to do that ?
… and if that is not possible… what is a better approach of passing data from one automation to another ?
alias: "Notify: Garage door open"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.zone_9
for:
hours: 0
minutes: 5
seconds: 0
to: "on"
condition:
- condition: or
conditions:
- condition: time
before: "08:00:00"
after: "18:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
- condition: time
before: "17:00:00"
after: "09:00:00"
weekday:
- fri
- thu
- wed
- tue
- mon
action:
- service: mqtt.publish
data:
qos: 0
topic: garage/status
payload: " Garage left open on {{now().strftime(\"%a, %d-%b-%y at %-I:%M %p\")}}"
retain: true
- service: automation.trigger
data:
skip_condition: false
target:
entity_id: automation.trigger_sms_or_notification
mode: single
second service
alias: "Trigger: SMS or Notification"
description: ""
trigger: []
condition: []
action:
- if:
- condition: or
conditions:
- condition: time
before: "08:00:00"
after: "21:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: time
before: "10:00:00"
after: "21:00:00"
weekday:
- sun
- sat
then:
- service: notify.sms
data:
message: MQTT topic value in here...'
target: 0xx
alias: >-
Call a service 'Notifications: Send a notification with sms on
0xx
- service: notify.sms
data:
message: 'MQTT topic value in here...'
target: 0xxx
alias: >-
Call a service 'Notifications: Send a notification with sms on
0xxx
enabled: false
else:
- service: notify.mobile_app_pixel_pro
data:
title: Warning!
message: MQTT topic value in here...'
- service: notify.mobile_app_a_iphone
data:
message: MQTT topic value in here...'
title: Warning!
enabled: false
mode: single