Hi,
I try to use the serial printer output from a alarm system to monitor who goes in and out to try to setup automations and scripts in homeassistant to open or close a door lock or switch lights and music on or off when someone goes in or out.
I setup a sensor like:
sensor:
- platform: serial
name: "Cupboard Alarm"
serial_port: /dev/ttyUSB0
baudrate: 19200
bytesize: 8
parity: N
stopbits: 1
value_template: "{{
{
'id': value[1:4],
'date': value[14:22],
'time': value[5:13],
'door': value.split('op')[1].split('\x0e')[0].strip(),
'user': value.split('gebruiker')[1][2:].split('\x0f')[0].strip(),
}
}}"
The sensor output without the value_template set is:
1283 22:19:01 18/08/20 Toegang verleend op Deur 1 voor gebruiker 2 Donald
How to create 1 sensor with attributes ‘id’ ‘date’ ‘time’ ‘door’ ‘user’ from it without creating multiple sensors?
Hope someone can point me in the right direction.
Regards,
Donald.