WTH is Griddy Price not working with Automation?

When I try to use Griddy in an automation it never triggers.

platform: numeric_state
entity_id: sensor.lz_houston_price_now
above: 13

Using the GUI I noticed that it puts the entries in what feels reverse order.

above: 13
entity_id: sensor.lz_houston_price_now
platform: numeric_state

FULL YAML

- id: '1597930090955'
  alias: New Automation
  description: ''
  trigger:
  - above: '13'
    entity_id: sensor.lz_houston_price_now
    platform: numeric_state
  condition: []
  action:
  - data:
      message: Electricity is high.
    service: notify.notify
  mode: single

suggest you vote for your own request

1 Like

Is that sensor going from below 13 to above 13? If it’s already above 13 when you create/turn on the automation it won’t trigger.

1 Like

The order is changed to alphabetical by the UI and it does not matter.

Yes, it crosses the 13 boundary. I also tried another automation for below 13 to do something else.

Is the automation on, and does manually triggering it work? Go to developer tools > states, click on the info icon next to the automation entity ID, and click EXECUTE. Alternatively, go to developer tools > services and manually trigger the automation with the automation.trigger service. Check for errors in the log related to the automation too.

If manually triggering it works, is the entity ID in the trigger correct?

Also, post the entire automation YAML.

1 Like

So a reason for numeric state not to work, might be caused by the actual contents of the state not being a number (or not being able to parse it as a number).

What is the exact contents of the state for this sensor? For example, does the state itself contain a currency symbol?

You can check this via the developer tools -> states.

2 Likes

A problem that has basically WTH’d me for a while, is this: how to tell whether a state is a number, or the text of that number. (Am I making sense?)

ie, is 13 and integer or the text of an integer?

1 Like

Both. States are always a text (string). However, the numeric_state tries to consume it as a number (casting). So the input doesn’t matter that much.

That said, if the actual state contained $14,55 (as a text) it won’t be interpretable as a number (due to the dollar sign).

1 Like

image

I updated the post with the full yaml.

Execute from dev tools runs all-the-way through and sends me the notification regardless of the sate of the sensor. I don’t see anything in the log related to the automation after triggering it manually.

Below are two of the Griddy automations I’m using that work for me.

- id: '1572630019168'
  alias: Stop TWIZZY Charging if Power Spikes
  description: ''
  trigger:
  - above: '30'
    entity_id: sensor.lz_houston_price_now
    platform: numeric_state
  condition:
  - condition: zone
    entity_id: person.twizzy_model_3
    zone: zone.home
  action:
  - service: system_log.write
    data_template:
      level: error
      logger: homeassistant.components.mylogger
      message: 'Ran Automation: Stop TWIZZY Charging if Power Spikes: sensor.lz_houston_price_now:
        {{ states("sensor.lz_houston_price_now") }}'
  - service: switch.turn_off
    entity_id: switch.twizzy_charger_switch
- id: '1572630450054'
  alias: Power Spike Over (Home)
  description: ''
  trigger:
  - below: '30'
    entity_id: sensor.lz_houston_price_now
    platform: numeric_state
  condition:
  - condition: state
    entity_id: variable.power_spike_in_progress
    state: '1'
  - condition: state
    entity_id: sensor.806_alexander_family
    state: home
  action:
  - data_template:
      level: error
      logger: homeassistant.components.mylogger
      message: 'Ran Automation: Power Spike Over (Home): {{ states("sensor.lz_houston_price_now")
        }}'
    service: system_log.write
  - data:
      value: 0
      variable: power_spike_in_progress
    service: variable.set_variable
  - data:
      event: alexander_power_spike_over_home
    service: ifttt.trigger
  - entity_id: switch.power_spike_mode
    service: switch.turn_off
  - service: script.home_turn_on_devices
  - scene: scene.ifttt_return_to_schedule
2 Likes

If you really want to know what’s going on, add this to your config:

logger:
  default: info
  logs:
    homeassistant.core: debug

Then restart HA. That will add log messages to home-assistant.log for every state change in the system. Then you can search for state_changed events for sensor.lz_houston_price_now. Then you’ll absolutely know what it’s doing, or not doing. The log will also show whenever an automation is triggered.

You may be able to use the Logbook, but I’m not sure there will be enough detail there. I almost never use that, especially when home-assistant.log has all the detail I usually ever need.

This is working for me. I’d recommend dropping those single ticks around the 13.

  - alias: 'Power-HardSpike'
    trigger:
      - platform: numeric_state
        entity_id: sensor.griddy
        above: 15
    action:
      - service: script.set_power_by_state      
      - service: notify.main_channel
        data:
          message: 'Power has spiked to {{ states.sensor.griddy.state }}.  Please conserve power use.'
      - condition: state
        entity_id: input_boolean.silent_mode
        state: 'off'
      - service: rest_command.announce_sonos
        data_template:
          message: 'Power has spiked to {{ states.sensor.griddy.state }}.  Please conserve power use.'