Files
homeassistant-prod/pyscript/example.py
Bastian Schnorbus 188671fd7e update
2025-05-04 15:46:15 +02:00

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)