Turn Smart Bulb On When Ring Battery Drops Below 20%

Hi, I’m a newbie with little coding experience.
I have a ring doorbell, with poor battery life, and I would like on of my Hue bulbs to light up red when the Ring battery drops below 20%.
I’m using a Gauge Card in HA.
I asked ChatGPT and got the following code

type: gauge
entity: sensor.front_door_battery
needle: true
min: 20
severity:
  green: 75
  yellow: 45
  red: 20

name: Ring Doorbell Battery
alias: Battery Low - Turn Hue Red
description: Turns a Philips Hue bulb red when a battery drops below 20%.
trigger:
  - platform: numeric_state
    entity_id: sensor.front_door_battery
    below: 20
action:
  - service: light.turn_on
    target:
      entity_id: light.hue_lightstrip_plus_1
    data:
      brightness: 125
      color_name: red
mode: single

Shockingly, it doesn’t work. I would very much like some advice on how I might resolve the issue.

As I’m sure you will know, it’s only the code below red:20 that came from ChatGPT.

Thanks in advance
Dave

How are you testing it?

What’s the current state value of sensor.front_door_battery?

If it’s already below 20 then it’s too late to trigger the Numeric State Trigger (which only triggers at the moment when the sensor’s value decreases and crosses the threshold value of 20).

Hi,
Thanks for responding.
The actual value is currently 84 and I set the code to that. Ultimately I want it to trigger at 20%.
The battery does drain quite quickly. So, I’ve now changed the trigger value to 83.
Now I’ll have to wait.

Thanks again.

You can add a second trigger, say something like

  - platform: time_pattern
    minutes: "*"

That will trigger the automation every minute on the minute. That’s a faster way to at least test whether the problem is somehow with the action: block or whether it’s with the numeric_state trigger.

Thanks
I’ve put that code in but I’m not sure what you mean, sorry.

Ah yes it should trigger the light every minute but it doesn’t.
So I’ve got to figure out how to get the light to come, I think.

Maybe a more basic question… where is the code for the automation, specifically? Did you pull what you pasted out of a file or the GUI (and which file or which part of the GUI)? Does that code, including the gauge code and the uatomation code, all come from the same place?

1 Like

Yep, what @d921 said just above me. Your first post contains two separate pieces of code - the first bit goes in the gauge card config in your dashboard, while the rest is an automation you need to set up in Settings > Automations.

If you’re pasting that entire code in one place, then nothing will work.

Thanks for replying

This is GUI code

type: gauge
entity: sensor.front_door_battery
needle: true
min: 20
severity:
  green: 75
  yellow: 45
  red: 20

This is ChatGPT Code

alias: Battery Low - Turn Hue Red
description: Turns a Philips Hue bulb red when a battery drops below 20%.
trigger:
  - platform: time_pattern
    minutes: "*"
  - platform: numeric_state
    entity_id: sensor.front_door_battery
    below: 83
action:
  - service: light.turn_on
    target:
      entity_id: light.hue_lightstrip_plus_1
    data:
      brightness: 125
      color_name: red
mode: single

Does that help?
Thanks

Yep, the ChatGPT code should go in your automations. Automation itself looks fine (was gonna suggest using minutes: "/1" but yours should work).

If you added the above as an automation and it didn’t work, you can check the Traces for the automation to see why it didn’t run.

Excellent, thanks a lot.
So that works.
I’ve now removed the minutes trigger and will have to wait for the battery level to drop.
Er, is that right?

Dave

Go to developer tools → states, search for sensor.front_door_battery and set it to what ever you like. Then you can test without waiting.

1 Like

Excellent, thanks very much :grinning: