For those who also want the following functionality:
- Read the current status on the board (using the sensor mentioned in the earlier post)
- Persist this status (as the sensor might update while displaying the new message)
- Write a new message to the board (I use it to write the energy usage to the board)
- After a certain period (e.g. 1 minute) write back the previous message
I’ve modified the local rest call to also be able to write back the direct JSON structured lines as retrieved by the rest sensor:
rest_command:
vestaboard_message:
url: "http://{{vestaboard_local_ip_address}}:7000/local-api/message"
method: POST
content_type: application/json
verify_ssl: false
headers:
X-Vestaboard-Local-Api-Key: {{vestaboard_local_api_key}}
payload: >
{% if rawlines is defined %}
{{ rawlines |to_json }}
{% else %}
{% set map = {
' ': 0,
'A': 1,
'B': 2,
'C': 3,
'D': 4,
'E': 5,
'F': 6,
'G': 7,
'H': 8,
'I': 9,
'J': 10,
'K': 11,
'L': 12,
'M': 13,
'N': 14,
'O': 15,
'P': 16,
'Q': 17,
'R': 18,
'S': 19,
'T': 20,
'U': 21,
'V': 22,
'W': 23,
'X': 24,
'Y': 25,
'Z': 26,
'1': 27,
'2': 28,
'3': 29,
'4': 30,
'5': 31,
'6': 32,
'7': 33,
'8': 34,
'9': 35,
'0': 36,
'!': 37,
'@': 38,
'#': 39,
'$': 40,
'(': 41,
')': 42,
'-': 44,
'+': 46,
'&': 47,
'=': 48,
';': 49,
':': 50,
"'": 52,
'"': 53,
'%': 54,
',': 55,
'.': 56,
'/': 59,
'?': 60,
'°': 62,
'\xc1': 63,
'\xc2': 64,
'\xc3': 65,
'\xc4': 66,
'\xc5': 67,
'\xc6': 68,
'\xc7': 69,
'~': 0
} %}
{% set l = lines %}
{% set ns = namespace(l = [], m = []) %}
{% for i in range(6) %}
{% set s = "" if i >= l|length else l[i] %}
{% set a = '{:<22}'.format(s)|upper|list %}
{% set ns.l = [] %}
{% for c in a %}
{% set ns.l = ns.l + ([map[c if c in map else '?']]) %}
{% endfor %}
{% set ns.m = ns.m + [ns.l] %}
{% endfor %}
{{ ns.m |to_json }}
{% endif %}
Note you can now use the lines: or rawlines: when transmitting data. Using rawlines will expect a JSON formatted line as retrieved by the sensor in my earlier post.
You will need to create text_input parameters to store the lines (can also be done as a helper in the GUI):
input_text:
vb_line1:
name: Param Vb Line1
vb_line2:
name: Param Vb Line2
vb_line3:
name: Param Vb Line3
vb_line4:
name: Param Vb Line4
vb_line5:
name: Param Vb Line5
vb_line6:
name: Param Vb Line6
Now for an example of a script - which I’ve made discoverable by Alexa:
vestaboard_show_message:
alias: Vestaboard - Show Message
sequence:
- service: homeassistant.update_entity
data: {}
target:
entity_id: sensor.vestaboard_line1
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: input_text.set_value
data:
value: '{{states(''sensor.vestaboard_line1'')}}'
target:
entity_id: input_text.vb_line1
- service: input_text.set_value
data:
value: '{{states(''sensor.vestaboard_line2'')}}'
target:
entity_id: input_text.vb_line2
- service: input_text.set_value
data:
value: '{{states(''sensor.vestaboard_line3'')}}'
target:
entity_id: input_text.vb_line3
- service: input_text.set_value
data:
value: '{{states(''sensor.vestaboard_line4'')}}'
target:
entity_id: input_text.vb_line4
- service: input_text.set_value
data:
value: '{{states(''sensor.vestaboard_line5'')}}'
target:
entity_id: input_text.vb_line5
- service: input_text.set_value
data:
value: '{{states(''sensor.vestaboard_line6'')}}'
target:
entity_id: input_text.vb_line6
- service: rest_command.vestaboard_message
data:
lines:
- "Your text here - line 1"
- "Your text here - line 2"
- "Your text here - line 3"
- "Your text here - line 4"
- "Your text here - line 5"
- "Your text here - line 6"
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: rest_command.vestaboard_message
data:
rawlines:
- "{{states('input_text.vb_line1')}}"
- "{{states('input_text.vb_line2')}}"
- "{{states('input_text.vb_line3')}}"
- "{{states('input_text.vb_line4')}}"
- "{{states('input_text.vb_line5')}}"
- "{{states('input_text.vb_line6')}}"
mode: single
icon: mdi:counter
Hope this is of help to anyone