Integrating Temperature Sensor into Automation: A Success Story

Hi everyone, I wanted to share my recent success in integrating a temperature sensor into a smart home automation system. I’ve been working on a project where I wanted to receive notifications based on outdoor temperature readings, and I thought I’d document my journey in case it helps others.

Initially, I set up a simple automation using a Hue outdoor motion sensor, which includes a temperature sensor. The goal was to send a notification to my iPhone when the temperature dropped below a certain threshold. Here’s the YAML configuration I started with:

yaml
alias: Temp msg for phone
description: ‘’
trigger:

  • platform: time
    at: ‘07:00’
    condition:
  • type: is_temperature
    condition:
    device: device_id
    entity_id: sensor.hue_outdoor_motion_sensor_1_temperature
    domain: sensor
    below: 5
    action:
  • service: notify.mobile_app_rix_iphone11
    data:
    message: Below 5 degrees
    title: Outside temp
    mode: single

This setup worked well for detecting when the temperature was below 5 degrees. However, I wanted to take it a step further by including the actual temperature reading in the notification message. After some research, I found a helpful example on the forum and modified my YAML accordingly:

yaml
alias: Temp msg for phone
description: ‘’
trigger:

  • platform: time
    at: ‘07:00’
    condition:
  • type: is_temperature
    condition:
    device: device_id
    entity_id: sensor.hue_outdoor_motion_sensor_1_temperature
    domain: sensor
    below: 5
    action:
  • service: notify.mobile_app_rix_iphone11
    data_template:
    message: ‘{{ states(“sensor.hue_outdoor_motion_sensor_1_temperature”) }}’
    title: Outside temp
    mode: single

At first, I encountered an error related to template values, but after some troubleshooting, I realized the issue was with how the template was structured. Ensuring that the message field was properly formatted as a string resolved the problem. Now, my automation works seamlessly, sending notifications with the exact temperature reading when the threshold is met.

This experience taught me the importance of carefully reviewing YAML syntax, especially when working with templates. It also highlighted the value of community resources and forums for troubleshooting and learning new techniques. I hope sharing this helps someone else looking to integrate temperature data into their automations!

Happy automating! :star2: