Hi, I’ve been running traces on on of my automations as it isn’t working as expected.
I decided to go for a coffee and ran a couple of updates which were waiting. One of them being a core update.
When I got back the updates had completed but the traces have disappeared “no traces found”.
Is this normal?
Will I have to wait for the automation to run again before I can run a trace on it again?
Or can anyone see if my yaml is right here…
Judging by the times of the entity changes it should have hit the wait_for_trigger section which is there in case the charger doesn’t change state quickly enough (which it didn’t last night) in which case it should wait 5 minutes to give it time to change state (which it did well within the 5 minutes last night). In which case it should have carried out the action and run the script. But it didn’t.
I was about to run the trace to see exactly where it failed in my code but the traces have disappeared
I haven’t had the exact scenario arise since posting this so can’t get a trace to look at.
As far as I can tell it boils down to the “wait for trigger” section in the attached yaml code isn’t working as expected. From the timings it should have hit the first wait for trigger because the charger was still ‘Boosting’. A few seconds later the ‘Boosting’ changed state which should have led to the
action:script.turn_off_growatt_battery_first
being executed. But it didn’t.
Is my logic faulty in the code below?
I’m no yaml or HA expert
If your HA instance restarted (like what usually happens automatically after a core update), then the wait_for_trigger as well as the trigger itself, gets wiped out.
5 minutes isn’t too long of a time to run into this scenario, but you seem to have been unlucky enough to have a restart occur right when the automation was running.
TLDR: probably nothing’s wrong with your code. Just try to avoid restarts while automations are running and you’ll be perfectly fine.
Sorry, just to clarify. The restart didn’t occur while the automation was running. It happened while I was going through the traces after the event. So nothing interrupted the flow of the automation.
In that case, can you double check your automation above?
Both your if and your else are pointing to the status NOT changing to Boosting (not is_state('sensor.myenergi_zappi_********_status' , 'Boosting'), then calling the same service.
Basically, whatever happens, it seems like your automation will always run that script.
Is this intended, or do you have an extra not in one of the if/else state checks?
Here’s the whole automation. The logic is, or should be, that, when intelligent despatching turned on my solar system is set up to charge the battery and supply the load from the grid at cheap rate. When it turns off basically reverse the operation, checking if it happens during peak or of peak time and if the charger is actually charging (this can take a little time to happen, hence the wait for trigger sections.
alias: IOG Intelligent Despatching Turns Off
description: >-
Trigger on Intelligent Dispatching turns off.
Test myenergi Home Charger Status is NOT Boosting
Then setup Growatt to load first. Reset values changed in Peak Hours
Intelligent Despatching Turns ON
triggers:
- entity_id:
- binary_sensor.octopus_energy_a_********_intelligent_dispatching
from: "on"
to: "off"
trigger: state
conditions: []
actions:
- if:
- condition: state
entity_id: binary_sensor.iogpeakhours
state: "on"
then:
- if:
- condition: template
value_template: >-
{{ not is_state('sensor.myenergi_zappi_********_status' ,
'Boosting') }}
then:
- action: script.turn_off_growatt_battery_first
data: {}
else:
- condition: state
entity_id: binary_sensor.iogpeakhours
state: "on"
- wait_for_trigger:
- value_template: >-
{{ not is_state('sensor.myenergi_zappi_********_status' ,
'Boosting') }}
for:
minutes: 5
trigger: template
continue_on_timeout: false
- action: script.turn_off_growatt_battery_first
data: {}
else:
- condition: state
entity_id: binary_sensor.iogpeakhours
state: "on"
- wait_for_trigger:
- value_template: >-
{{ not is_state('sensor.myenergi_zappi_********_status' ,
'Boosting') }}
for:
minutes: 5
trigger: template
continue_on_timeout: false
- action: script.turn_off_growatt_battery_first
data: {}
mode: single
First things first. Please format your code correctly. You did it right in your first post but butchered in in the following entries.
Hit the code icon, then paste your code, not vice versa.
Secondly, all the conditions above are expecting the status to not be boosting. If that is what you wanted, a single wait for trigger with a timeout of 5 mins should have been enough. No it’s or else’s required.
Finally you have a extra else at the bottom which doesn’t make much sense, because you’ve already defined an else further up.
Please post the correctly formatted automation, and explain again what each step of the automation should do
Apologies for delay. I have now reformatted the code. For some reason I don’t get the same results when I do this on my mobile.
Over the weekend I had very similar set of charge times come up and it all worked exactly as expected this time.
Not sure what happened that led to this post as I lost the traces before I could examine them in detail.
As it seems to be doing as I want at the moment I’ll wait and see if the problem comes up again and make sure I don’t do any updates before I examine the traces as that should make finding the issue much easier.
Thanks for the input and apologies for the poor formatting.