Permalink
Browse files

Revert script calls

  • Loading branch information...
aderusha committed Sep 18, 2018
1 parent 3bfdf3e commit 3ce5f5f66588d2bfe0394b4be35c25d5c31d9201
@@ -239,42 +239,4 @@ automation:
- service: input_number.set_value
data:
entity_id: 'input_number.hasp_plate01_activepage'
value: 1
script:
##############################################################################
# Selects the font size to best fit the input text
# Required arguments:
# topic: the topic to publish to
# text: the text that should be sized
hasp_plate01_font_size_select:
sequence:
- service: mqtt.publish
data:
topic: "{{topic}}"
payload_template: >
{% set string_length = text)|length %}
{% if string_length <= 6 -%}
3
{% elif (string_length > 6) and (string_length <= 10) %}
2
{% elif (string_length > 10) and (string_length <= 15) %}
1
{% else %}
0
{%- endif %}"
# Updates the message on the specified object making sure that the text fits
# Required arguments:
# objectId: the id of the object on the HASP you want to update, eg: p[2].b[5]
# text: the text that should be sent
hasp_plate01_update_message:
sequence:
- service: script.hasp_plate01_font_size_select
data:
topic: "hasp/plate01/command/{{objectId}}.font"
text: "{{text}}"
- service: mqtt.publish
data:
topic: "hasp/plate01/command/{{objectId}}.txt"
payload_template: "{{text}}"
value: 1
@@ -9,22 +9,38 @@ automation:
topic: 'hasp/plate01/status'
payload: 'ON'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
objectId: 'p[1].b[4]'
text: '"Lights On"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[1].b[4].font'
payload: '2'
- service: mqtt.publish
data:
objectId: 'p[1].b[5]'
text: '"Daylight"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[1].b[4].txt'
payload: '"Lights On"'
- service: mqtt.publish
data:
objectId: 'p[1].b[6]'
text: '"Night"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[1].b[5].font'
payload: '2'
- service: mqtt.publish
data:
objectId: 'p[1].b[7]'
text: '"Lights Off"'
topic: 'hasp/plate01/command/p[1].b[5].txt'
payload: '"Daylight"'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[1].b[6].font'
payload: '2'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[1].b[6].txt'
payload: '"Night"'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[1].b[7].font'
payload: '2'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[1].b[7].txt'
payload: '"Lights Off"'
# Trigger scene.lights_on when p[1].b[4] pressed
- alias: hasp_plate01_p1_SceneButton4
@@ -35,7 +51,7 @@ automation:
action:
service: scene.turn_on
entity_id: scene.lights_on
# Trigger scene.daylight when p[1].b[5] pressed
- alias: hasp_plate01_p1_SceneButton5
trigger:
@@ -64,4 +80,4 @@ automation:
payload: 'ON'
action:
service: scene.turn_on
entity_id: scene.lights_off
entity_id: scene.lights_off
@@ -9,14 +9,22 @@ automation:
topic: 'hasp/plate01/status'
payload: 'ON'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
objectId: 'p[2].b[4]'
text: "\"{{(now().strftime('%I')|int)~now().strftime(':%M')}}\""
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[2].b[4].font'
payload: '3'
- service: mqtt.publish
data:
objectId: 'p[2].b[5]'
text: "\"{{now().strftime('%B ') ~ now().day}}\""
topic: 'hasp/plate01/command/p[2].b[4].txt'
payload_template: "\"{{(now().strftime('%I')|int)~now().strftime(':%M')}}\""
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[2].b[5].font'
payload_template: '{% set datelength = (now().strftime("%B ") ~ now().day)|length %}{% if datelength <= 6 -%}3{% elif (datelength > 6) and (datelength <= 10) %}2{% elif (datelength > 10) and (datelength <= 15) %}1{% else %}0{%- endif %}'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[2].b[5].txt'
payload_template: "\"{{now().strftime('%B ') ~ now().day}}\""
# Send the current time every minute
- alias: hasp_plate01_p2_ClockUpdate
@@ -29,11 +37,11 @@ automation:
entity_id: 'binary_sensor.plate01_connected'
state: 'on'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
objectId: 'p[2].b[4]'
text: "\"{{(now().strftime('%I')|int)~now().strftime(':%M')}}\""
topic: 'hasp/plate01/command/p[2].b[4].txt'
payload_template: "\"{{(now().strftime('%I')|int)~now().strftime(':%M')}}\""
# Send "Month Day" every day, scaling font to fit
# 0 consolas 24 - 20 chars x 2 lines (wrapped)
# 1 consolas 32 - 15 chars x 2 lines (wrapped)
@@ -48,7 +56,11 @@ automation:
entity_id: 'binary_sensor.plate01_connected'
state: 'on'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[2].b[5].font'
payload_template: '{% set datelength = (now().strftime("%B ") ~ now().day)|length %}{% if datelength <= 6 -%}3{% elif (datelength > 6) and (datelength <= 10) %}2{% elif (datelength > 10) and (datelength <= 15) %}1{% else %}0{%- endif %}'
- service: mqtt.publish
data:
objectId: 'p[2].b[5]'
text: "\"{{now().strftime('%B ') ~ now().day}}\""
topic: 'hasp/plate01/command/p[2].b[5].txt'
payload_template: "\"{{now().strftime('%B ') ~ now().day}}\""
@@ -11,11 +11,19 @@ automation:
topic: 'hasp/plate01/status'
payload: 'ON'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
objectId: 'p[2].b[6]'
text: '"{{states.sensor.weather_temperature.state}}F"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[2].b[6].font'
payload: '3'
- service: mqtt.publish
data:
objectId: 'p[2].b[7]'
text: '"{{states.sensor.weather_current.state|wordwrap(20, wrapstring="\\r")}}"'
topic: 'hasp/plate01/command/p[2].b[6].txt'
payload_template: '"{{states.sensor.weather_temperature.state}}F"'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[2].b[7].font'
payload_template: '{% if states.sensor.weather_current.state|length <= 6 -%}3{% elif (states.sensor.weather_current.state|length > 6) and (states.sensor.weather_current.state|length <= 10) %}2{% elif (states.sensor.weather_current.state|length > 10) and (states.sensor.weather_current.state|length <= 15) %}1{% else %}0{%- endif %}'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[2].b[7].txt'
payload_template: '"{{states.sensor.weather_current.state|wordwrap(20, wrapstring="\\r")}}"'
@@ -8,18 +8,30 @@ automation:
topic: 'hasp/plate01/status'
payload: 'ON'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[3].b[4].font'
payload: '2'
- service: mqtt.publish
data:
objectId: 'p[3].b[4]'
text: '"Light 1"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[3].b[4].txt'
payload: '"Light 1"'
- service: mqtt.publish
data:
objectId: 'p[3].b[5]'
text: '"Light 2"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[3].b[5].font'
payload: '2'
- service: mqtt.publish
data:
objectId: 'p[3].b[6]'
text: '"Light 3"'
topic: 'hasp/plate01/command/p[3].b[5].txt'
payload: '"Light 2"'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[3].b[6].font'
payload: '2'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[3].b[6].txt'
payload: '"Light 3"'
- service: mqtt.publish
data:
topic: 'hasp/plate01/command/p[3].b[7].font'
@@ -34,7 +46,7 @@ automation:
action:
service: homeassistant.toggle
entity_id: light.light_1
# Toggle light2 when p[3].b[5] pressed
- alias: hasp_plate01_p3_ToggleLight2
trigger:
@@ -69,7 +81,7 @@ automation:
homeassistant.turn_on
{%- endif %}
entity_id: group.light_toggle_group
# Toggle colors on p[3].b[4] when light1 changes
- alias: hasp_plate01_p3_ToggleColor1
trigger:
@@ -189,4 +201,4 @@ automation:
"Lights Off"
{%- else -%}
"Lights On"
{%- endif %}
{%- endif %}
@@ -7,19 +7,19 @@ automation:
topic: 'hasp/plate01/status'
payload: 'ON'
action:
- service: script.hasp_plate01_update_message
- service: mqtt.publish
data:
objectId: 'p[4].b[4]'
text: '"Light 1"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[4].b[4].txt'
payload: '"Light 1"'
- service: mqtt.publish
data:
objectId: 'p[4].b[5]'
text: '"Light 2"'
- service: script.hasp_plate01_update_message
topic: 'hasp/plate01/command/p[4].b[5].txt'
payload: '"Light 2"'
- service: mqtt.publish
data:
objectId: 'p[4].b[6]'
text: '"Light 3"'
topic: 'hasp/plate01/command/p[4].b[6].txt'
payload: '"Light 3"'
- alias: hasp_plate01_p4_Dimmer7UpdateHass
trigger:
- platform: mqtt
@@ -29,7 +29,7 @@ automation:
data_template:
entity_id: light.light_1
brightness: '{{ trigger.payload }}'
- alias: hasp_plate01_p4_Dimmer7UpdateHASP
trigger:
- platform: state
@@ -39,7 +39,7 @@ automation:
data_template:
topic: 'hasp/plate01/command/p[4].b[7].val'
payload_template: '{{states.light.light_1.attributes.brightness|default(0)|int}}'
- alias: hasp_plate01_p4_Dimmer8UpdateHass
trigger:
- platform: mqtt
@@ -49,7 +49,7 @@ automation:
data_template:
entity_id: light.light_2
brightness: '{{ trigger.payload }}'
- alias: hasp_plate01_p4_Dimmer8UpdateHASP
trigger:
- platform: state
@@ -59,7 +59,7 @@ automation:
data_template:
topic: 'hasp/plate01/command/p[4].b[8].val'
payload_template: '{{states.light.light_2.attributes.brightness|default(0)|int}}'
- alias: hasp_plate01_p4_Dimmer9UpdateHass
trigger:
- platform: mqtt
@@ -69,7 +69,7 @@ automation:
data_template:
entity_id: light.light_3
brightness: '{{ trigger.payload }}'
- alias: hasp_plate01_p4_Dimmer9UpdateHASP
trigger:
- platform: state
@@ -78,4 +78,4 @@ automation:
- service: mqtt.publish
data_template:
topic: 'hasp/plate01/command/p[4].b[9].val'
payload_template: '{{states.light.light_3.attributes.brightness|default(0)|int}}'
payload_template: '{{states.light.light_3.attributes.brightness|default(0)|int}}'
Oops, something went wrong.

0 comments on commit 3ce5f5f

Please sign in to comment.