Using a "Template Number Value" instead of static number

Chaps
I need your help. Lets be honest, I’m just not very good at YML

OK, what am I trying to achieve. I have various security cameras that trigger outside floodlights. They work perfectly when we have good weather. Introduce a heavy rain shower and they introduce a lot of false positives. I am able to configure the sensitivity of these cameras using HA

Solution. I have a counter that tracks the number of motion detections within a certain time period. If that crosses a certain thresh-hold within a certain time, it triggers an automation where I decrease the motion sensitivity of the camera. I can do this with a STATIC number, what I would like to do is use a “Template Number” to gradually reduce the sensitivity.

This is my automation to reduce the sensitivity with a FIXED NUMBER (20)

triggers:
  - trigger: time_pattern
    minutes: /30
conditions:
  - condition: numeric_state
    entity_id: counter.counter_reolink_patio_motion_detected
    above: 25
actions:
  - device_id: 569573b6d0276d50b0ef488f8310016c
    domain: number
    entity_id: 4e60c6037eb655ff299c8018a27e31d4
    type: set_value
    value: 20
mode: single

I have created a TEMPLATE NUMBER that reduces 10 from the current cameras motion sensitivity
number.template_number_reolink_patio_motion_sensitivity_minus_10

{{ states('number.reolink_garden_motion_sensitivity') | float(0) - 10 }}

I’d like to use that template result in my automations actions instead of manually setting it to a fixed number and I just can’t figure out how to do it (If it’s even possible)

Thanks for any help or telling me I’m doing this the wrong way

Brucey

I amazed myself (not difficult) and figured it out

actions:
  - data:
      entity_id: number.reolink_garden_motion_sensitivity
      value: "{{ states('number.reolink_garden_motion_sensitivity') | float(0) - 10 }}"
    action: number.set_value

Copying here in case it helps anyone else

Hi, good you found it yourself!

Please take the time to mark the solution as the answer, you do that by selecting the three dots under the post:

image

Then select the check box:

image
By doing so:

  • this thread can be useful to other users as well (this thread comes up as solution when starting a thread which is similar to yours).
  • this prevents that someone else steps in trying to help

Thanks for giving back to the community! :+1:

1 Like

Thanks mate, will do, didn’t know where to find that although I’ve seen others do it
Thanks buddy

1 Like

it wasn’t showing since you did not put your topic in any category so therefor I changed it. :wink:

1 Like