update
This commit is contained in:
12
pyscript/example.py
Normal file
12
pyscript/example.py
Normal 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)
|
||||
Reference in New Issue
Block a user