Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95565

Access state information from service_call event automation

$
0
0

@hasshoolio wrote:

I have an automation that notifies me if the garage open and close services are called. I do this because I don’t want notified when the garage is open/closed from our normal remotes/wall button. I only want know when home assistant is triggering the change. The automation works well but I’d like to include either the current, to, or from state in the message. I don’t see state info available in the call_service event type and trying to derive it isn’t working either.

- alias: Garage Service Called
  trigger:
  - platform: event
    event_type: call_service
    event_data:
      service_data:
        entity_id: cover.garage_door_opener_2
      domain: cover
      service: close_cover
  - platform: event
    event_type: call_service
    event_data:
      service_data:
        entity_id: cover.garage_door_opener_2
      domain: cover
      service: open_cover
  action:
    service: notify.emailnotify
    data_template:
      message: 'The garage door service {{ trigger.event.data.service  }} was called. Current state is {{states("trigger.event.data.service_data.entity_id")}}'

The above results in this message

Home Assistant / The garage door service open_cover was called. Current state is unknown

Calling {{states(“cover.garage_door_opener_2”)}} works and shows the originating state , but that’s no fun :slight_smile:

I’ve looked at even logs when the service is called and things look right to me… Is there any way to pull state info into this service call triggered notify automation?

Thanks!

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>