Hi guys, I am fairly new to home automation. I get a lot of info by just searching on the forum pages. Most of the times it helps me enough to figure out the problems I’m facing. As I can’t cope with this specific problem and spent hours on it, I want to ask here to put me in the right directions
I recently added a configuration with a motion detector that switches off the lights in the living room after X minutes without any presence. What happens is that we sit down and occasionally the Neo Coolcam PIR doesn’t see us sitting. I also have a Neo Coolcam power plug with monitor capabilities. What I want to do is telling HA that if the power plug is using more than 10 watts, that the lights are staying on in the living room. The power plug will be used with the tv.
This feature has to complement the code underneath:
I’ve also added this, but I keep struggling in filling in the details of ‘value_template’ Note: value template does not consist any good code. Just a summary of what I want it to do.
1. sensor:
2. - platform: yr
3. - platform: template
4. sensors:
5. energy_meter:
6. value_template: "{{ "if >10 W is used, do not turn off the lights" }}"
7. unit_of_measurement: 'W'
I used pages like HA template sensor, but I can’t find answers to what I have to fill in to let it work. I also looked at the templating page, and many other things, but it’s just a bridge too far at the moment to figure it out myself.
Off the top of my head, I would create a binary template sensor based on the energy measurement value and then use that sensor’s state as a condition in the automation.
Yes. The state of the template sensor should be either true or false, so I think your condition should test for true/false rather than <10 though. I’m kind of sleepy this morning after a late night so I may be off a bit, but I think that’s right.
Everything works ok now. I tested everything with the code onderneath. When the tv screen is turned off, the wattage is below 19 W. When fully in use, it is around 54 W. If I now turn off the tv, my light will turn off within the specified time. When the tv is on, it won’t. Yay! It’s getting better and better to understand everything within the code
[code]sensor:
platform: template
sensors:
energy_meter:
value_template: “{{states(‘sensor.energie_tv_woonkamer_power_8_8’) | int < 19 }}”
unit_of_measurement: W [/code]
[code]automation:
alias: ‘Light go out after 20 sec at midnight’
trigger:
platform: state
entity_id: binary_sensor.pir_woonkamer_sensor_6_0
to: ‘off’
for:
seconds: 20
condition:
condition: numeric_state
entity_id: sensor.energie_tv_woonkamer_power_8_8
below: ‘19’
action: