13 lines
583 B
Python
13 lines
583 B
Python
@service
|
|
def hello_world(action=None, id=None, brt=None):
|
|
"""hello_world example using pyscript."""
|
|
log.info(f"hello world: got action {action} id {id}")
|
|
w = state.get("weather.forecast_home")
|
|
attr = state.getattr("weather.forecast_home")
|
|
log.info(f"hello world: got action {w} - attributes {attr}")
|
|
log.info(f"hello world: cloudcoverage {attr.get('cloud_coverage')}")
|
|
if action == "turn_on" and id is not None:
|
|
light.turn_on(entity_id=id, brightness=brt)
|
|
elif action == "fire" and id is not None:
|
|
event.fire(id, param1=12, param2=80)
|