test_stuff.yaml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: template
  26. value_template: >
  27. {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
  28. false
  29. {% else %}
  30. true
  31. {% endif %}
  32. - platform: event
  33. event_type: timer.finished
  34. event_data:
  35. entity_id: timer.piano_lamp_control_timer
  36. condition:
  37. condition: template
  38. value_template: >
  39. {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
  40. false
  41. {% else %}
  42. true
  43. {% endif %}
  44. action:
  45. - service_template: light.turn_{{states('input_boolean.piano_light_wanted_state')}}
  46. entity_id: light.piano_lamp_repeater
  47. - service_template: >
  48. {% if state_attr('sensor.piano_lamp_repeater_status', 'status') == states('input_boolean.piano_light_wanted_state') %}
  49. timer.cancel
  50. {% else %}
  51. timer.start
  52. {% endif %}
  53. entity_id: timer.piano_lamp_control_timer
  54. timer:
  55. piano_lamp_control_timer:
  56. duration: '00:00:30'