Hi,
I am trying to send serial data to HA.
My setup is the HASS operating system on a Raspberry Pi.
below shows a log entry verifying the serial data is indeed coming in via a USB port.
I am using a template to strip off the incoming data - config.YAML below
As shown in the log, a correct temperature of 24.25 is read from the data string.
My problem is that I want to display this a a Temperature on a graph, but currently it is a string.
Can someone tell me how to alter the code to do this,
thanks
Logger:
170_Temperature2 changed to 24.25 triggered by state of serial_sensor changed to $:170:85:0:24.25:*
Config.YAML:
sensor:
- platform: serial
name: serial_sensor
serial_port: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A105NIQ6-if00-port0
baudrate: 115200
template:
- trigger:
- platform: state
entity_id: sensor.serial_sensor
sensor:
- name: 170_Temperature2
state: >-
{% set d = trigger.to_state.state.split(':') %}
{{ d[4] if d | count > 2 and d[1] == '170' else this.state }}
- name: 170_Signal
state: >-
{% set d = trigger.to_state.state.split(':') %}
{{ d[2] if d | count > 2 and d[1] == '170' else this.state }}