Explorar el Código

Corrected event trigger py_script func

pi hace 4 años
padre
commit
037a0014c4
Se han modificado 1 ficheros con 22 adiciones y 4 borrados
  1. 22 4
      pyscript/wall_buttons.py

+ 22 - 4
pyscript/wall_buttons.py

@@ -21,10 +21,30 @@ AttributeError: 'dict' object has no attribute 'context'
 # 3: Morning-mode
 # 4: All OFF
 
+
+
+"""
+
+ERROR:
+2021-05-13 20:52:14 ERROR (MainThread) [custom_components.pyscript.function] run_coro: got exception Traceback (most recent call last):
+  File "/config/custom_components/pyscript/eval.py", line 710, in call
+    raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}")
+TypeError: hallway_wall_button() called with unexpected keyword arguments: state
+
+
+got button_pressed: kwargs={
+    'trigger_type': 'event', 
+    'event_type': 'button_pressed', 
+    'context': Context(user_id=None, parent_id=None, id='01ce32cfcc4bed50ce9301ae967fa951'), 
+    'entity_id': 'switch.mode_panel_4', 
+    'state': 'off'}
+"""
+
+
 @event_trigger( "button_pressed" )
-def hallway_wall_button(entity_id=None):
+def hallway_wall_button(entity_id=None, state=None):
 
-    log.info(f"****************  got EVENT_CALL_SERVICE with {entity_id}")
+    log.info(f"****************  got EVENT_CALL_SERVICE with Id:{entity_id}  State:{state}")
 
     if( entity_id == 'switch.hall_switch' ):
         if( switch.group_button_all == 'on'):
@@ -43,5 +63,3 @@ def hallway_wall_button(entity_id=None):
     
     if( entity_id == 'switch.mode_panel_4' ):   # All OFF
         pyscript.state_goto_all_off()
-
-