test_stuff.yaml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. action:
  33. - service: >
  34. {% if states('input_boolean.piano_light_wanted_state') == "on" %}
  35. light.turn_on
  36. {% else %}
  37. light.turn_off
  38. {% endif %}
  39. entity_id: light.piano_lamp_repeater
  40. timer:
  41. piano_lamp_control_timer:
  42. duration: '00:00:30'