Last active
January 25, 2021 11:52
-
-
Save aderusha/46f4f89a116981da9bd6a477c32d73f4 to your computer and use it in GitHub Desktop.
hasp_Display_Clock.yaml
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
blueprint: | |
name: plate01 p[x].b[y] displays a clock | |
description: A HASP button displays a clock | |
domain: automation | |
input: | |
haspconnected: | |
name: HASP Device | |
description: "Select the HASP device" | |
selector: | |
entity: | |
integration: mqtt | |
domain: binary_sensor | |
device_class: connectivity | |
hasppage: | |
name: HASP Page | |
description: "Select the HASP page (1-11) for the clock" | |
selector: | |
number: | |
min: 1 | |
max: 11 | |
mode: box | |
haspbutton: | |
name: HASP Button | |
description: "Select the HASP button (4-15) for the clock. Not all pages will have all buttons, refer to the object map in the HASP documentation." | |
selector: | |
number: | |
min: 4 | |
max: 15 | |
mode: box | |
font: | |
name: Clock Font | |
description: "Select the font for the clock:" | |
selector: | |
number: | |
min: 0 | |
max: 10 | |
mode: box | |
xcen: | |
name: Text horizontal alignment | |
description: "Horizontal text alignment 0:Left 1:Center 2:Right" | |
selector: | |
number: | |
min: 0 | |
max: 2 | |
mode: box | |
ycen: | |
name: Text vertical alignment | |
description: "Vertical text alignment 0:Top 1:Center 2:Bottom" | |
selector: | |
number: | |
min: 0 | |
max: 2 | |
mode: box | |
hour24: | |
name: 24 hour clock display | |
selector: | |
boolean: | |
ampm: | |
name: AM/PM suffix | |
selector: | |
boolean: | |
mode: single | |
max_exceeded: silent | |
variables: | |
haspconnected: !input haspconnected | |
haspname: '{{ haspconnected.split(".")[1].split("_connected")[0] }}' | |
hasppage: !input hasppage | |
haspbutton: !input haspbutton | |
font: !input font | |
xcen: !input xcen | |
ycen: !input ycen | |
hour24: !input hour24 | |
ampm: !input ampm | |
trigger: | |
- platform: state | |
entity_id: !input haspconnected | |
to: "on" | |
- platform: homeassistant | |
event: start | |
- platform: time_pattern | |
seconds: 0 | |
condition: | |
- condition: state | |
entity_id: !input haspconnected | |
state: "on" | |
action: | |
- choose: | |
# Every minute, update the clock text | |
- conditions: | |
- condition: template | |
value_template: '{{ trigger.platform == "time_pattern" }}' | |
sequence: | |
- service: mqtt.publish | |
data_template: | |
topic: "hasp/{{haspname}}/command/p[{{hasppage}}].b[{{haspbutton}}].txt" | |
payload: '{% if hour24 == true %}{% set format="%-H"%}{% else %}{% set format="%I"%}{% endif %}"{{(now().strftime(format)|int)~now().strftime(":%M")}} {% if ampm == true %}{{now().strftime("%p")|lower}}{% endif %}"' | |
# Otherwise, apply the font+clock to the button | |
default: | |
- service: mqtt.publish | |
data_template: | |
topic: "hasp/{{haspname}}/command/json" | |
payload: '{% if hour24 == true %}{% set format="%-H"%}{% else %}{% set format="%I"%}{% endif %}["p[{{hasppage}}].b[{{haspbutton}}].font={{font}}","p[{{hasppage}}].b[{{haspbutton}}].xcen={{xcen}}","p[{{hasppage}}].b[{{haspbutton}}].ycen={{ycen}}","p[{{hasppage}}].b[{{haspbutton}}].txt=\"{{(now().strftime(format)|int)~now().strftime(":%M")}} {% if ampm == true %}{{now().strftime("%p")|lower}}{% endif %}\""]' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment