state_goto.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """
  2. def getCurrentState():
  3. if( light.main_button_1 == 'on' && ) # All ON
  4. light.main_button_2 == 'on' &&
  5. light.main_button_3 == 'on' &&
  6. light.main_button_4 == 'on' ):
  7. return 1
  8. elif( light.main_button_1 == 'off' && ) # Window
  9. light.main_button_2 == 'off' &&
  10. light.main_button_3 == 'off' &&
  11. light.main_button_4 == 'on' ):
  12. return 2
  13. elif( light.main_button_1 == 'off' && ) # Morning
  14. light.main_button_2 == 'on' &&
  15. light.main_button_3 == 'off' &&
  16. light.main_button_4 == 'on' ):
  17. return 3
  18. elif( light.main_button_1 == 'off' && ) # All OFF
  19. light.main_button_2 == 'off' &&
  20. light.main_button_3 == 'off' &&
  21. light.main_button_4 == 'off' ):
  22. return 4
  23. """
  24. @service
  25. def state_goto_all_on():
  26. log.info(f"********* ALL ON ***********")
  27. switch.turn_on(entity_id='switch.group_button_all')
  28. light.turn_on(entity_id='light.tradfri_bulb')
  29. switch.turn_on(entity_id='switch.tradfri_outlet') # Sovrum ON
  30. @service
  31. def state_goto_window():
  32. log.info(f"********* WINDOW ***********")
  33. switch.turn_off(entity_id='switch.group_button_all')
  34. light.turn_on(entity_id=' light.main_button_4')
  35. light.turn_off(entity_id='light.tradfri_bulb')
  36. switch.turn_on(entity_id='switch.tradfri_outlet') # Sovrum ON
  37. @service
  38. def state_goto_morning():
  39. log.info(f"********* MORNING ***********")
  40. switch.turn_off(entity_id='switch.group_button_all')
  41. light.turn_on(entity_id=' light.main_button_2')
  42. light.turn_on(entity_id=' light.main_button_4')
  43. light.turn_off(entity_id='light.tradfri_bulb')
  44. switch.turn_off(entity_id='switch.tradfri_outlet') # Sovrum OFF
  45. @service
  46. def state_goto_all_off():
  47. log.info(f"********* ALL OFF ***********")
  48. switch.turn_off(entity_id='switch.group_button_all')
  49. light.turn_off(entity_id='light.tradfri_bulb')
  50. switch.turn_off(entity_id='switch.tradfri_outlet') # Sovrum OFF