Skip to content

Simple Service Example

Matthew Scoville edited this page Sep 13, 2020 · 3 revisions

Simple Service example that checks a binary sensor and outputs pass/fail based on the state.

The Service trigger is most useful for ensuring the rest of your script works. You can use it to test what will eventually be a time trigger to make sure the logic works without having to wait for the time trigger event.

"""
Service script
"""
@service
def test():
    if binary_sensor.workday == 'on':
        log.info(f"Service Trigger test: fail")
        pass
    else:
        log.info(f"Service Trigger test: pass")
        pass