Invalid config for [Notify]

Hello. Very new to Home Assistant and this is my first time posting. I hope I tagged the code properly with the back-ticks. If not, Please tell me where to find the procedure and I’ll update.

I’m trying to send an email when my temp sensor is above a certain temperature. Below is
the code which generates a “Invalid config for [notify]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 12).” error when I check it with the Configuartion
Validator. I copied the code from the SMTP integrations page. What am I missing? Thanks.

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
  - platform: google_translate

# group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#
notify:
  - name: "gmail"
    platform: smtp
    server: "smtp.gmail.com"
    port: 587
    timeout: 15
    sender: "[email protected]"
    encryption: starttls
    username: "[email protected]"
    password: "Password_for _above_address"
    recipient:
      - "MY Email Address"
    sender_name: "Home Assistant Says:"
#   End Gmail Config

  - alias: 'Temp Outdoor Sensor Above 70'
    trigger:
    - platform: numeric_state
      entity_id: sensor.testing_outdoor_temperature
      above: 70
#      for:
#        minutes: 40
    action:
      service: notify.gmail
      data:
        message: 'Test outdoor sensor above 70 degrees'
        data:
          priority: 1
          sound: gamelan

This looks like an automation. But its under notify. You need to move it to automations.yaml or add automation other: right above it so HA knows that’s the config of an automation. Feel free to change other in that to any word you want, doesn’t have to be other.

1 Like

I moved that part to the Automation file which cleared up my error. Thank you for that.

My temp sensor is sitting at 76 which is above my threshold but I’m not receiving any email alerts.
I checked the Automations section in Settings and this automation is enabled. Still not receiving any emails though. When I test my email notify, I do receive an email. Thoughts? Thanks

That automation will trigger when the temperature passes through that threshold. So if it was 69 and went to 72 that would trigger it. Since it’s 76 already there is no trigger. To work around that I usually create a binary sensor to be the trigger {{ states(‘sensor.temp’)|int > 70 }}

Couple of additional considerations:

  • occasionally I get bad sensor readings, and getting an alarm on a bad reading is a hassle. So I’ll typically run it through the Filter - Home Assistant to remove outliers.
  • it may be useful the change the threshold, enable and disable from dashboard.

Here’s an example from my house.


input_boolean:
  bedroom_thermostat_temperature_alarm_enable:
  bedroom_thermostat_temperature_alarm_high_enable:
  bedroom_thermostat_temperature_alarm_low_enable:

input_number:
  bedroom_thermostat_temperature_low_limit:
    min: -30
    max: 120
    step: 1
    unit_of_measurement: "°F"
    mode: box
  bedroom_thermostat_temperature_high_limit:
    min: -30
    max: 120
    step: 1
    unit_of_measurement: "°F"
    mode: box

sensor:
  - platform: filter
    name: "bedroom_thermostat_temperature_filter"
    entity_id: sensor.bedroom_thermostat_temperature
    filters:
      - filter: range
        lower_bound: 0
        upper_bound: 100
      - filter: outlier
        window_size: 4
        radius: 20

binary_sensor:
  - platform: template
    sensors:
      bedroom_thermostat_temperature_low_alert:
        value_template: '{{ is_state("input_boolean.bedroom_thermostat_temperature_alarm_enable","on") and is_state("input_boolean.bedroom_thermostat_temperature_alarm_low_enable","on") and states("sensor.bedroom_thermostat_temperature_filter")|float(100) < states("input_number.bedroom_thermostat_temperature_low_limit")|float(100) }}'
        delay_on: "00:30:00"
        device_class: "cold"
      bedroom_thermostat_temperature_high_alert:
        value_template: '{{ is_state("input_boolean.bedroom_thermostat_temperature_alarm_enable","on") and is_state("input_boolean.bedroom_thermostat_temperature_alarm_high_enable","on") and states("sensor.bedroom_thermostat_temperature_filter")|float(0) > states("input_number.bedroom_thermostat_temperature_high_limit")|float(0) }}'
        delay_on: "00:30:00"
        device_class: "heat"

alert:
  bedroom_thermostat_temperature_low:
    name: bedroom_thermostat_temperature low
    message: 'bedroom_thermostat_temperature low: {{ states("sensor.bedroom_thermostat_temperature") }} limit {{ states("input_number.bedroom_thermostat_temperature_low_limit") }}'
    done_message: 'bedroom_thermostat_temperature normal: {{ states("sensor.bedroom_thermostat_temperature") }}'
    entity_id: binary_sensor.bedroom_thermostat_temperature_low_alert
    state: "on"
    repeat: 120
    can_acknowledge: true
    skip_first: false
    notifiers:
      - sms_notifiers_all

  bedroom_thermostat_temperature_high:
    name:  bedroom_thermostat_temperature high
    message: ' bedroom_thermostat_temperature high: {{ states("sensor.bedroom_thermostat_temperature") }} limit {{ states("input_number.bedroom_thermostat_temperature_high_limit") }}'
    done_message: 'bedroom_thermostat_temperature normal: {{ states("sensor.bedroom_thermostat_temperature") }}'
    entity_id: binary_sensor.bedroom_thermostat_temperature_high_alert
    state: "on"
    repeat: 120
    can_acknowledge: true
    skip_first: false
    notifiers:
      - sms_notifiers_all

recorder:
  include:
    entities:
      - sensor.bedroom_thermostat_temperature_filter
      - binary_sensor.bedroom_thermostat_temperature_low_alert
      - binary_sensor.bedroom_thermostat_temperature_high_alert
      - input_number.bedroom_thermostat_temperature_low_limit
      - input_number.bedroom_thermostat_temperature_high_limit
      - input_boolean.bedroom_thermostat_temperature_alarm_enable
      - alert.bedroom_thermostat_temperature_low
      - alert.bedroom_thermostat_temperature_high
      - sensor.bedroom_thermostat_temperature

To make a new one for a different sensor. I just run this file though sed.


sed 's/bedroom_thermostat_temperature/studio_thermostat_temperature/g' temperature_template_package.yaml > /mnt/c/github/ha/packages/temperature_template_studio_thermostat_temperature_package.yaml

A numeric state trigger only fires when the value crosses your threshold. So in your case in order to receive an email sensor.testing_outdoor_temperature would have to be <= 70 and then go above 70. Then you wouldn’t receive another email until the sensor dropped back below 70 and crossed it again.

If you want to receive continuous notifications any time your value is above a threshold the easiest option is to use an alert rather then an automation. Create a threshold binary sensor with your sensor and your theshold and then create an alert that sends you a notification any time your binary sensor is on. See the doc for you can customize the resend interval and the message.

Another benefit is alerts can be turned off with alert.turn_off if its been on for a while and getting annoying (like if its above 70 all day and you’re tired of receive emails about it). This will stop notifiying you until the binary sensor goes off and back on again (or until you restart HA).