iOS Alerts

Hi,

I’m fairly new to HomeAssistant and have been muddling my way through moving some automation to HomeAssistant. I’ve been a little stumped on how to send iOS alerts to my phone and how to include a variable in my alert notification. I have 4 automations set up that trigger based on real time electricity pricing. They all seem to trigger and work properly, yet only 1 send an iOS notification (Turn on Mini Fridge automation). Also, I’d like it to output the current price when it does so, but currently it just spits out this:

Comed price is {state.sensor.comed_5_minute_price}
Mini Fridged turned back on.

Any help or points in the right direction are appreciated.

- id: '1611002510461'
  alias: Turn off Mini Fridge
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    above: '4'
  condition: []
  action:
  - domain: switch
    entity_id: switch.mini_refrigerator
    device_id: b66547973fab91f046e4f45a7eb9d479
    type: turn_off
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: Mini Fridge turned off
    title: Comed Hourly Price is {{sensor.comed_5_minute_price}}
  mode: single
- id: '1611018874449'
  alias: Turn on Mini Fridge
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    below: '4.0'
  condition: []
  action:
  - domain: switch
    entity_id: switch.mini_refrigerator
    device_id: b66547973fab91f046e4f45a7eb9d479
    type: turn_on
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: Mini Fridge turned back on
    title: Comed price is {state.sensor.comed_5_minute_price}
  mode: single`

Both of your templates are wrong:

Should be

title: "Comed price is {{ states('sensor.comed_5_minute_price' }}"

Take a look at the template docs here

You can always check your templates with Developer Tools -> Templates

Great, thanks very much for the point in the right direction and the help! The developer tools indicate this is working now.

Hi, I’m using this now and it still send the message as Comed price is [state.sensor.comed_5_minute_price}

title: "Comed price is {{ states('sensor.comed_5_minute_price') }}"

I’ve never had any luck with templating the title on a notify service.
Try swapping your title and message around.

Thanks. I’ll give that a try. The other thing I have not figured out is why only 1 of my 4 notifications works. 1 works literally every time. The others have not worked at all.

Probably the title is not templatable then.

Your 4 automations, do they work whrn dou execute them manually?

post your configuration as it now stands

I may have figured it out. I think it was a combination of some of these changes, plus I had to reload the automations, which I must have forgotten to do after 1 of the changes. I’m monitoring it now. I also realized I need to tweak the last part of the automation, depending on time of day and year. I need to look into how to do that now.

- id: '1611002510461'
  alias: Turn off Mini Fridge
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    above: '4.0'
  condition: []
  action:
  - domain: switch
    entity_id: switch.mini_refrigerator
    device_id: b66547973fab91f046e4f45a7eb9d479
    type: turn_off
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: "Comed price is {{ states('sensor.comed_5_minute_price') }}"
    title: Mini Fridge turned off
  mode: single
- id: '1611018874449'
  alias: Turn on Mini Fridge
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    below: '4.0'
  condition: []
  action:
  - domain: switch
    entity_id: switch.mini_refrigerator
    device_id: b66547973fab91f046e4f45a7eb9d479
    type: turn_on
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: "Comed price is {{ states('sensor.comed_5_minute_price') }}"
    title: Mini Fridge turned back on
  mode: single
- id: '1611251451579'
  alias: Turn off Humidifier
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    above: '4.0'
  condition: []
  action:
  - type: turn_off
    device_id: a627867f10c929f0229240a9bacd2630
    entity_id: switch.humidifier
    domain: switch
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: Humidifier turned off
    title: "Comed price is {{ states('sensor.comed_5_minute_price') }}"
  mode: single
- id: '1611251648758'
  alias: Turn on Humidifier
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    below: '4.0'
  condition: []
  action:
  - type: turn_on
    device_id: a627867f10c929f0229240a9bacd2630
    entity_id: switch.humidifier
    domain: switch
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: Humidifier turned back on
    title: "Comed price is {{ states('sensor.comed_5_minute_price') }}"
  mode: single
- id: '1611252261052'
  alias: Set Ecobee Comfort Profile to Precool when Hourly pricing is less than 0
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    below: '0'
  condition: []
  action:
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: Comed price is low!
    title: "Hourly pricing is less than zero ({{ states('sensor.comed_5_minute_price') }})"
  mode: single

If you are interested I can show you a way to consolidate those 5 automations into 1.

Very interested! I was realizing that it seems rather redundant, but was focused on making it work first and having them separate allowed me to make changes to just 1 and not others to test what worked. Thanks for your help!

I think this should work. Change clockbright to your sensor.

- alias: monitor comed
  trigger:
    - platform: numeric_state
      entity_id: input_number.clockbright
      below: 0.0
    - platform: numeric_state
      entity_id: input_number.clockbright
      above: 3.9
    - platform: numeric_state
      entity_id: input_number.clockbright
      below: 4.0

  condition:

  action:
    - service_template: '{% if trigger.to_state.state|float > 3.9 %}switch.turn_off{% else %}switch.turn_on{% endif %}'
      entity_id:
        - switch.humidifier
        - switch.mini_refrigerator

    - service: notify.mobile_app_phone
      data:
        title: "Monitor Comed"
        message: >
          Comed price is {{ trigger.to_state.state }}.
          {% if trigger.to_state.state|float < 0 %}
              Comed very low!!!
          {% endif %}
        data:
          ttl: 0
          sticky: true
          priority: high

Will this automation also turn it back on when the price changes to below 4.0 as well?

Yes it will, that’s what the service template handles for you.

It seems like this doesn’t replace the part about setting my EcoBee to pre-cooling that I have in my automations. I was hoping to do this when power is zero or less, but realized I only want to do this during the day in the winter, and anytime during the summer. Or maybe I could just set it to If Ecobee is set to heat mode, then do this, otherwise if set to cool mode do this…

From what I see in the automations you posted, all you are doing is sending a message when the comed is below zero which is my “Comed very low messge”. Did I miss something else?

If you are looking at doing something else when below zero, You can add a condition in the action section at the end to test for < 0 winter/summer logic.

This sets my thermostat to a precool mode when pricing is below zero.
EDIT: No, you’re right. It only sends a message for now. I didn’t figure out that automation yet. My mistake.

- id: '1611252261052'
  alias: Set Ecobee Comfort Profile to Precool when Hourly pricing is less than 0
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.comed_5_minute_price
    below: '0'
  condition: []
  action:
  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: Comed price is low!
    title: "Hourly pricing is less than zero ({{ states('sensor.comed_5_minute_price') }})"
  mode: single

Hi,

I am finally returning to this. I’m wondering how I can use your suggestion and now just notify my phone when devices turn on/off. I’m ditching the EcoBee part for now since I think IFTTT will be able to do some of that for me with some logic they’re building.

Here’s what I have now:

- alias: monitor comed
  trigger:
    - platform: numeric_state
      entity_id: sensor.comed_5_minute_price
      below: 0.0
    - platform: numeric_state
      entity_id: sensor.comed_5_minute_price
      above: 3.9
    - platform: numeric_state
      entity_id: sensor.comed_5_minute_price
      below: 4.0

  condition:

  action:
    - service_template: '{% if trigger.to_state.state|float > 3.9 %}switch.turn_off{% else %}switch.turn_on{% endif %}'
      entity_id:
        - switch.humidifier
        - switch.mini_refrigerator

I used to have something like this in there to notify me of the changes. Any idea how I can incorporate this?

  - device_id: 3f8d5522b14ec128970965ee77b37493
    domain: mobile_app
    type: notify
    message: "Comed price is {{ states('sensor.comed_5_minute_price') }}"
    title: Mini Fridge turned off