Skip to content

Instantly share code, notes, and snippets.

@dale3h
Created September 1, 2018 00:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dale3h/42ebc8dd3b2f3da56831313a538a43e8 to your computer and use it in GitHub Desktop.
Save dale3h/42ebc8dd3b2f3da56831313a538a43e8 to your computer and use it in GitHub Desktop.
[Home Assistant] If/Then Script
http:
...
trusted_networks:
- 127.0.0.1
rest_command:
ha_rest_api:
url: "http://localhost:8123/api/services/{{ service|replace('.', '/') }}"
method: post
content_type: application/json
payload: "{{ data|tojson }}"
script:
if_then:
alias: "If Then"
sequence:
- condition: template
value_template: "{{ if }}"
- service: rest_command.ha_rest_api
data_template:
service: "{{ service }}"
data: "{{ data }}"
automation:
- alias: "If/Then Test"
trigger:
- platform: state
entity_id: fan.dummy_fan
to: 'on'
action:
- service: script.if_then
data_template:
if: "{{ is_state('light.dummy_light_1', 'on') }}"
service: persistent_notification.create
data:
message: "Testing..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment