test_stuff.yaml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. light:
  2. - platform: rflink
  3. devices:
  4. newkaku_013242b6_2:
  5. name: Piano-lamp
  6. type: switchable
  7. newkaku_013242b5_2:
  8. name: Piano-lamp REPEATER
  9. type: switchable
  10. sensor:
  11. - platform: sql
  12. db_url: mysql://hassio:hassiopassword@192.168.1.110/RemoteRxLog
  13. queries:
  14. - name: Piano-lamp repeater status
  15. query: "SELECT IF(onOff>0,'on','off') AS status FROM RemoteRxLog.nexaLog where rxTx='R' and remote_id = '20071094' and button='2' order by ts desc LIMIT 1;"
  16. column: 'status'
  17. input_boolean:
  18. piano_light_wanted_state:
  19. name: Piano-lamp, wanted state
  20. initial: off
  21. icon: mdi:lightbulb
  22. automation:
  23. - alias: Piano-lamp control automation
  24. trigger:
  25. - platform: state
  26. entity_id: input_boolean.piano_light_wanted_state
  27. - platform: event
  28. event_type: timer.finished
  29. event_data:
  30. entity_id: timer.piano_lamp_control_timer
  31. condition:
  32. condition: template
  33. value_template: >
  34. {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
  35. false
  36. {% else %}
  37. true
  38. {% endif %}
  39. action:
  40. - service_template: light.turn_{{states('input_boolean.piano_light_wanted_state')}}
  41. entity_id: light.piano_lamp_repeater
  42. - service_template: light.turn_{{states('input_boolean.piano_light_wanted_state')}}
  43. entity_id: light.piano_lamp
  44. - service_template: >
  45. {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
  46. timer.cancel
  47. {% else %}
  48. timer.start
  49. {% endif %}
  50. entity_id: timer.piano_lamp_control_timer
  51. mode: single
  52. timer:
  53. piano_lamp_control_timer:
  54. duration: '00:00:30'