-
Notifications
You must be signed in to change notification settings - Fork 49
Comparing Pyscript to Home Assistant Automations
Daniel Lashua edited this page Oct 16, 2020
·
9 revisions
In Home Assistant:
- alias: some automation
trigger:
platform: state
entity_id: binary_sensor.test
to: 'on'
action:
- service: homeassistant.turn_on
entity_id: switch.test
In Pyscript:
@state_trigger('binary_sensor.test == "on"')
def turn_on():
homeassistant.turn_on(entity_id='switch.test')
In Home Assistant:
- alias: some automation
trigger:
platform: state
entity_id: binary_sensor.test
to: 'on'
from: 'off'
action:
- service: homeassistant.turn_on
entity_id: switch.test
In Pyscript:
@state_trigger('binary_sensor.test == "on" and binary_sensor.test.old == "off"')
def turn_on():
homeassistant.turn_on(entity_id='switch.test')
In Home Assistant:
- alias: some automation
trigger:
platform: state
entity_id: binary_sensor.test
action:
- service: homeassistant.turn_on
entity_id: switch.test
In Pyscript:
@state_trigger('True or binary_sensor.test')
def turn_on():
homeassistant.turn_on(entity_id='switch.test')
In Home Assistant:
- alias: some automation
trigger:
platform: template
value_template: "{{ is_state('binary_sensor.test', 'on') }}"
action:
- service: homeassistant.turn_on
entity_id: switch.test
In Pyscript:
@state_trigger('binary_sensor.test == "on"')
def turn_on():
homeassistant.turn_on(entity_id='switch.test')
In Home Assistant:
- alias: some automation
trigger:
platform: state
entity_id: binary_sensor.test
to: "on"
condition:
condition: template
value_template: "{{ is_state('input_boolean.test', 'on') }}"
action:
- service: homeassistant.turn_on
entity_id: switch.test
In Pyscript:
@state_trigger('binary_sensor.test == "on"')
@state_active('input_boolean.test == "on"')
def turn_on():
homeassistant.turn_on(entity_id='switch.test')