Can't enable automation

Ok, I thought maybe automation B was actually working ok but just controlling the wrong automation!

:smile:

1 Like

Now my automation has stopped working again.
I looked in the log and filtered out all that was about this automation and this is what I find.

2020-05-20 12:26:38 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:28:23 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:29:21 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:30:48 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:31:05 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:31:45 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:39:20 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-20 12:40:01 ERROR (MainThread) [homeassistant.components.automation] Entity id already exists - ignoring: automation.counter. Platform automation does not generate unique IDs
2020-05-22 09:49:51 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities automation.counter
2020-05-22 09:49:54 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities automation.counter

The last two lines is because I tried to enable the automation again.
When I enable the automation using this button:


It disable itself after one second and I get the last two lines in log.
And this has just happened. I have not done any changes to this automation or any of the states/variables used in the automation.

The first error messages (Entity id already exists - ignoring: automation.counter) seems to imply you have created more than one automation with the same entity_id (specifically, automation.counter.) In fact, it looks like youā€™ve defined 9 automations with that entity_id (since the error is shown 8 times.)

Please look in your yaml files to see where automation.counter is defined. It would appear it will show up 9 times.

I can have a look but Iā€™m very sure that is not the case.
If it was the case then I would always have this problem, not just once a month or every other month.

I guess another possibility is that you only have two with the same entity_id, but every time you reload automations you get the error. Do you know what you were doing at 12:26:38 and 12:28:23 and 12:29:21 ā€¦?

I have these two automations with this entity_id:


- id: '1583921283128'
  alias: Counter
  description: 'Count up one every second'
  trigger:
  - platform: time_pattern
    seconds: /1
  condition: []
  action:
  - entity_id: counter.counter
    service: counter.increment


- id: '1583921483424'
  alias: counter reset
  description: 'Reset counter to zero'
  trigger:
  - entity_id: counter.counter
    platform: state
    to: '9'
  - entity_id: switch.sonoff_1000b711c4
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - entity_id: counter.counter
    service: counter.reset

I have no clue what I did at those times. It was not today it was Wednesday.
I really do believe I was watching TV at the time, and not using HA at all

Those are automation.1583921283128 and automation.1583921483424, not automation.counter. Where do you have definitions for automation.counter?

EDIT: Sorry, I meant those are automation.counter and automation.counter_reset. Do you have another automation.counter somewhere?

EDIT 2: Um, actually, Iā€™m not sure what I mean! :sweat_smile: I forget now whether it uses the id or the alias in this situation to create the entity_id. If you donā€™t specify an id I know it uses the alias. Sorry, I think Iā€™ve been away from HA for too long!

EDIT 3: Ok, just gave those a try. They do indeed create entity_idā€™s automation.counter and automation.counter_reset. So, do you have another automation defined somewhere whose alias is also counter?

I have just created these automations in the GUI and that is it.
I have not created anything else, just the counter which is named counter.

But the thing is that it works most of the time, and then sometimes it just stops working for no reason.

Edit: I see your edit 3 now.
No. I opened the automations.yaml in notepad and searched for ā€œcounterā€ and this is what I found.
There is no more automations with the entity counter. Or even anything that has the word counter or count.

I wonder if maybe this is similar to an issue that was noticed with scripts. That is, if a script is reloaded while it is running it can lead to an issue like this. Could be the same thing is happening with automations. And since this one runs every second, thereā€™s a fairly high probability it will be running if automations are reloaded.

Do you use the automation reload feature?

Automation reloadā€¦
Hmmmā€¦

Do you mean configuration -> server controls -> reload automations?

Yes that can happen when I create new automations but I donā€™t think I did that at that time since Iā€™m quite sure I was watching Survivor on TV.

But you are right about that with it could be a problem with reloading since it is always running.

Yes, thatā€™s what I was referring to.

BTW, this is the issue I mentioned concerning reloading running scripts. I had started working on overhauling the scripting & automation code, and much of that work has already been completed, but got bogged down recently. Although Iā€™ve already fixed that bug, I havenā€™t been able to submit it yet due to other prerequisites that havenā€™t been finished yet.

Anyway, how do you have your logger configured? If you have full debug enabled then there could quite possibly be clues in home-assistant.log when this happens.

When you reload the automations can you watch the screen to see if there is an error flash up on the screen ?
Usually in the lower left corner.

I can have a look, canā€™t do it right now.
Will report back when I have time.

I have no clue.
Didnā€™t know this was a setting but of course it isā€¦ Why wouldnā€™t it :slight_smile:
What should I look for in configuration.yaml (I assume?)

Itā€™s documented here. You can add this to configuration.yaml:

logger:
  default: debug

That will create a lot of information in home-assistant.log, but itā€™s the best way to figure out why this is happening. You can always remove it later.

I will give that a try and see if I can force the error occur.
I donā€™t think I will have the time today or tomorrow. But I will report back when I have more information.

1 Like