wall_buttons.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from homeassistant.const import EVENT_STATE_CHANGED
  2. """
  3. trigger file.wall_buttons.hallway_wall_button got event trigger, running action
  4. (kwargs = {
  5. 'trigger_type': 'event',
  6. 'event_type': 'button_pressed',
  7. 'context': Context(user_id=None,
  8. parent_id=None,
  9. id='67d442d5b0b4c1f3308417722801f709'),
  10. 'entity_id': 'switch.hall_switch',
  11. 'state': 'on'
  12. })
  13. kwargs={
  14. 'trigger_type': 'state',
  15. 'var_name': 'input_select.light_mode',
  16. 'value': 'Morning',
  17. 'old_value': 'All on',
  18. 'context': <homeassistant.core.Context object at 0x7ff02cc49800>}
  19. # Mode Panel:
  20. # 1: All ON
  21. # 2: Windows
  22. # 3: Morning-mode
  23. # 4: All OFF
  24. @event_trigger(EVENT_CALL_SERVICE)
  25. def monitor_service_calls(**kwargs):
  26. log.info(f"got EVENT_CALL_SERVICE with kwargs={kwargs}")
  27. The events below (mode panel 1-4) are incoming as a rflink, newkaku-switch.
  28. """
  29. @event_trigger( "button_pressed" )
  30. def hallway_wall_button(entity_id=None, state=None):
  31. log.info(f"*************** * got EVENT_CALL_SERVICE with Id:{entity_id} State:{state}")
  32. if( entity_id == 'switch.hall_switch' ):
  33. pyscript.handleWallButtonPressed()
  34. if( entity_id == 'switch.mode_panel_1' ): # All ON
  35. input_select.light_mode = 'All on'
  36. if( entity_id == 'switch.mode_panel_2' ): # Window
  37. input_select.light_mode = 'Windows'
  38. if( entity_id == 'switch.mode_panel_3' ): # Morning
  39. input_select.light_mode = 'Morning'
  40. if( entity_id == 'switch.mode_panel_4' ): # All OFF
  41. input_select.light_mode = 'All off'
  42. if( entity_id == 'switch.mode_panel_kwl' ): # Kitchen work lights
  43. input_boolean.toggle(entity_id='input_boolean.kitchen_worklights')
  44. # This will trigger kitchen_worklights_button_trigger()