wall_buttons.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """
  2. trigger file.wall_buttons.hallway_wall_button got event trigger, running action
  3. (kwargs = {
  4. 'trigger_type': 'event',
  5. 'event_type': 'button_pressed',
  6. 'context': Context(user_id=None,
  7. parent_id=None,
  8. id='67d442d5b0b4c1f3308417722801f709'),
  9. 'entity_id': 'switch.hall_switch',
  10. 'state': 'on'
  11. })
  12. kalle = kwargs.context.get("entity_id", None)
  13. ^
  14. AttributeError: 'dict' object has no attribute 'context'
  15. """
  16. # Mode Panel:
  17. # 1: All ON
  18. # 2: Windows
  19. # 3: Morning-mode
  20. # 4: All OFF
  21. @event_trigger( "button_pressed" )
  22. def hallway_wall_button(entity_id=None):
  23. log.info(f"**************** got EVENT_CALL_SERVICE with {entity_id}")
  24. if( entity_id == 'switch.hall_switch' ):
  25. if( switch.group_button_all == 'on'):
  26. pyscript.state_goto_all_off()
  27. else:
  28. pyscript.state_goto_all_on()
  29. if( entity_id == 'switch.mode_panel_1' ): # All ON
  30. pyscript.state_goto_all_on()
  31. if( entity_id == 'switch.mode_panel_2' ): # Window
  32. pyscript.state_goto_window()
  33. if( entity_id == 'switch.mode_panel_3' ): # Morning
  34. pyscript.state_goto_morning()
  35. if( entity_id == 'switch.mode_panel_4' ): # All OFF
  36. pyscript.state_goto_all_off()