This commit is contained in:
Bastian Schnorbus
2025-05-04 15:46:15 +02:00
parent dc9575ff33
commit 188671fd7e
7 changed files with 637 additions and 2 deletions

12
pyscript/example.py Normal file
View File

@@ -0,0 +1,12 @@
@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)