Sending temperature data to syslog based on time

Hi all,
I have an aqara temperature sensor which is working fine and I have configured a notify integration that can be used to send messages to my rsyslog daemon. This is all on a Debian box with Home Assistant (not Hass.io). I can define a trigger so that when the temperature changes, a message is logged to rsyslog and that is all smiley and good :slight_smile:

However, my end goal is to send the temperature to rsyslog every X minutes regardless of whether it has changed or not. I already have a second notify integration that logs a basic text message every 10 seconds (for testing purposes, it will be longer in the end). What I am struggling with is how to get the temperature from the sensor to send in the 10 second log message.

Here is my automation block:

- id: '9990000000002'
  alias: 10s to syslog
  trigger:
  - platform: time_pattern
    seconds: /10
  condition: []
  action:
  - data_template:
      message: "TEMP = {{ sensor.multi01_3.to_state }} "
    service: notify.iot_event

On the states page in HA, I see the entity as sensor.multi01_3 and the state shows the temp ok. When running HA, the error message says sensor doesn’t exist (full message below). I think I am missing something basic with what I am trying to do but not sure where to look or what it is :frowning:

Full error message:

2019-11-06 17:46:10 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'sensor' is undefined

For completeness, here is my notify block for syslog:

- name: iot_event
  platform: syslog
  facility: local7
  priority: 1

Any help would be greatly appreciated :slight_smile:

Thanks,
Rich

Instead of

Try message: "TEMP = {{ states("sensor.multi01_3") }} "

2 Likes

Hi @silvrr,
This is great and it works, although I had to sort out the quotes so that it looks like this:

message: "TEMP = {{ states('sensor.multi01_3') }} "

But you were spot on :slight_smile: I thought I had tried something similar when I was playing around with it earlier but I guess not.

Thanks very much for the help and a speedy reply.

Cheers,
Rich

Glad it worked, sorry for the slip up on the quotes.