Instantly share code, notes, and snippets.
Created
December 30, 2018 17:54
-
Star
1
(1)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save Snipercaine/2db450835bb6e750cb28425c99ff3937 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ############################################################################## | |
| # Automations for handling toggle state buttons on page 3 | |
| automation: | |
| # Set font and text for toggle buttons on device connection | |
| - alias: hasp_bench_p6_ToggleInit | |
| trigger: | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[4].font' | |
| payload: '1' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[4].txt' | |
| payload: '"Plug1"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[5].font' | |
| payload: '1' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[5].txt' | |
| payload: '"Plug2"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[6].font' | |
| payload: '1' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[6].txt' | |
| payload: '"Plug3"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[7].font' | |
| payload: '1' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[7].txt' | |
| payload: '"USB1"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[8].font' | |
| payload: '1' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[8].txt' | |
| payload: '"USB2"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[9].font' | |
| payload: '2' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[9].txt' | |
| payload: '"B9"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[10].font' | |
| payload: '2' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[10].txt' | |
| payload: '"B10"' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[11].font' | |
| payload: '2' | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[11].txt' | |
| payload: '"B11"' | |
| # Toggle light1 when p[6].b[4] pressed | |
| - alias: hasp_bench_p6_ToggleLight1 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[4]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.plugstrip_1 | |
| # Toggle light2 when p[6].b[5] pressed | |
| - alias: hasp_bench_p6_ToggleLight2 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[5]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.plugstrip_2 | |
| # Toggle light3 when p[6].b[6] pressed | |
| - alias: hasp_bench_p6_ToggleLight3 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[6]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.plugstrip_3 | |
| # Toggle light3 when p[6].b[7] pressed | |
| - alias: hasp_bench_p6_b7 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[7]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.usb_1 | |
| # Toggle light3 when p[6].b[8] pressed | |
| - alias: hasp_bench_p6_b8 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[8]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.usb_2 | |
| # Toggle light3 when p[6].b[9] pressed | |
| - alias: hasp_bench_p6_b9 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[9]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.usb_1 | |
| # Toggle light3 when p[6].b[10] pressed | |
| - alias: hasp_bench_p6_b10 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[10]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.usb_1 | |
| # Toggle light3 when p[6].b[11] pressed | |
| - alias: hasp_bench_p6_b11 | |
| trigger: | |
| - platform: mqtt | |
| topic: 'hasp/bench/state/p[6].b[11]' | |
| payload: 'ON' | |
| action: | |
| - service: switch.toggle | |
| entity_id: switch.usb_1 | |
| # Toggle all light_toggle_group when p[6].b[7] pressed | |
| # - alias: hasp_bench_p6_ToggleAll | |
| # trigger: | |
| # - platform: mqtt | |
| # topic: 'hasp/bench/state/p[6].b[7]' | |
| # payload: 'ON' | |
| # action: | |
| # - service_template: > | |
| # {% if states.group.light_toggle_group.state == "on" -%} | |
| # homeassistant.turn_off | |
| # {%- else -%} | |
| # homeassistant.turn_on | |
| # {%- endif %} | |
| # entity_id: group.light_toggle_group | |
| # Toggle colors on p[6].b[4] when light1 changes | |
| - alias: hasp_bench_p6_ToggleColor1 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.plugstrip_1 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[4].bco' | |
| payload_template: >- | |
| {% if states.switch.plugstrip_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[4].pco' | |
| payload_template: >- | |
| {% if states.switch.plugstrip_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[5] when light1 changes | |
| - alias: hasp_bench_p6_ToggleColor2 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.plugstrip_2 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[5].bco' | |
| payload_template: >- | |
| {% if states.switch.plugstrip_2.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[5].pco' | |
| payload_template: >- | |
| {% if states.switch.plugstrip_2.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[6] when light1 changes | |
| - alias: hasp_bench_p6_ToggleColor3 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.plugstrip_3 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[6].bco' | |
| payload_template: >- | |
| {% if states.switch.plugstrip_3.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[6].pco' | |
| payload_template: >- | |
| {% if states.switch.plugstrip_3.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[7] when light1 changes | |
| - alias: hasp_bench_p6_b7 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.usb_1 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[7].bco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[7].pco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[8] when light1 changes | |
| - alias: hasp_bench_p6_b8 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.usb_2 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[8].bco' | |
| payload_template: >- | |
| {% if states.switch.usb_2.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[8].pco' | |
| payload_template: >- | |
| {% if states.switch.usb_2.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[9] when light1 changes | |
| - alias: hasp_bench_p6_b9 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.usb_1 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[9].bco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[9].pco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[10] when light1 changes | |
| - alias: hasp_bench_p6_b10 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.usb_1 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[10].bco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[10].pco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} | |
| # Toggle colors on p[6].b[11] when light1 changes | |
| - alias: hasp_bench_p6_b11 | |
| trigger: | |
| - platform: state | |
| entity_id: switch.usb_1 | |
| - platform: state | |
| entity_id: 'binary_sensor.bench_connected' | |
| to: 'on' | |
| - platform: homeassistant | |
| event: start | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedbackgroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_selectedforegroundcolor | |
| - platform: state | |
| entity_id: input_number.hasp_bench_unselectedforegroundcolor | |
| action: | |
| - service: mqtt.publish | |
| data: | |
| topic: 'hasp/bench/command/p[6].b[11].bco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedbackgroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedbackgroundcolor.state | int }} | |
| {%- endif %} | |
| - service: mqtt.publish | |
| data_template: | |
| topic: 'hasp/bench/command/p[6].b[11].pco' | |
| payload_template: >- | |
| {% if states.switch.usb_1.state == "on" -%} | |
| {{ states.input_number.hasp_bench_selectedforegroundcolor.state | int }} | |
| {%- else -%} | |
| {{ states.input_number.hasp_bench_unselectedforegroundcolor.state | int }} | |
| {%- endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment