Hi there,
I want an automation that is turning off my 3d printer when the wifi plug’s power consumption is below a certain value for a specific amount of time. So nothing special but I can’t get it to work:
- alias: turn of 3d printer
trigger:
platform: numeric_state
entity_id: sensor.gsnd_3dprinter_energy_power
below: 65
for:
minutes: 15
condition:
- condition: state
entity_id: switch.gsnd_3dprinter
state: 'on'
action:
- service: homeassistant.turn_off
entity_id: switch.gsnd_3dprinter
Calling the automation manually is turning off the printer. It also worked once but never again. Can you tell me where my mistake is? thanks!
EDIT: This is the said sensor (it was below 50W for at least 15 minutes):
I can’t see anything obviously wrong with your automation.
But: In my config I’m using template sensors for all my power consumption related automations. And I know there was a reason I started with that, but I don’t remember it anymore. Yet, I’m quite sure, it was some problem with defining thresholds directly in the automation trigger.
- id: kg_drucker_ausschalten
alias: KG Drucker ausschalten (wenn im Standby / Display aus)
initial_state: true
trigger:
- entity_id: sensor.kg_drucker_status
platform: state
to: 'standby'
for:
minutes: 2
action:
- service: switch.turn_off
entity_id: switch.kg_drucker
As an extra advantage, the template sensor provides “human readable” states and history graphs for the entities. This is a history graph for an e-Bike charger I turn off with an automation when charging is complete:
With @mjoshd suggestion the automation worked once. Tried to trigger it a 2nd time and I had no success.
Does anyone know what happens when the plug is unavailable? Will the data count as above my set trigger?
I think I figured it out:
The logs showed that my tasmota plug was unavailable from time to time. My guess is that there is power data missing (missing as in NaN?) and the automation will never be triggered.
I followed this post since other seem also have these unstable connections:
So far the automation triggered twice succesfully.
Is it still working? I am trying same thing but don’t know where to stat. Currently I have D-link W215, but willing to buy another one if needed. I don’t even know how to read power from HA.
I was also thinking about prevention to power off while power is higher than selected amount.
Can you give some directions? I don’t know where to write those lines you posted… Currently I have Home Assistant installed on Rpi 4.
Start reading about automations here and maybe look up your device here to get started. I recommend you learn a bit about home assistant in general before you paste code snippets.