Simple Service Example - custom-components/pyscript GitHub Wiki
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