Sorry, i don’t see a counter service on my HA. Maybe i need something more?
you need to add the component and restart… It’s like any other component you add.
You mean if i add that service in the config, after the restart it will be added to all the services? Didn’t know this…
You aren’t adding a service, you are adding a component. Like adding input_boolean will give you access to input_boolean.turn_on…
Ok, good to know… Thanks again…
Sorry, now i get this error when restarting HA:
2018-12-06 14:03:47 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: extra keys not allowed @ data['condition'][1]['state']. Got None
not a valid value for dictionary value @ data['condition'][1]['condition']. Got None. (See /home/homeassistant/.homeassistant/configuration.yaml, line 29). Please check the docs at https://home-assistant.io/components/automation/
Maybe doesn’t like ‘state: 0’ ? Maybe i must put numeric_state? No, if i put numeric_state i get the same error…
EDIT: seems solved after putting ‘0’ as state instead 0.
probably want to change that condition to a value template or a numeric_state
change
- condition: state
entity_id: counter.meteo_ed_agenda
state: 0
to
- condition: template
value_template: "{{ state('counter.meteo_ed_agenda') | int == 0 }}"
The error disappeared when putting single quote around 0. You think it’s better to use the template?
It’s up to you, i don’t think it matters as long as it works.
Ok, i’ll test it tomorrow morning…
@petro I tested the automation, but it was not triggered by the activated motion sensor. It was triggered by the time, i.e. the automation started at 9:00 o’clock instead when the motion sensor was triggered, and why at 9 when the condition started at 8:30 ? I am sure no motion was triggered before 9 (only maybe 5-6 hours before).
well, the only way you can be sure about that is to check the history for each device:
binary_sensor.motion_sensor_158d0001a92ca1 and input_boolean.mauhome.
If either of those turned on at 9, that’s what caused it to trigger.
About the motion sensor it was off till 09:12 (after the automation was triggered) and for the input_boolean i had not in the logbook so cannot determinate his state in that hour… i will investigate better later, but if the motion sensor was off, why the automation started?
Because your automation will trigger if there is motion or if you arrive home.
Ah ok, but could it be better to have both conditions on to trigger it? And in this case how to modify the automation?
I’m not sure why you would, do you just want it to trigger only when you are home? If so, take the home input boolean out of the trigger and place it into the condition.
it’s an automation that start a script and a radio when i activate that motion sensor in the morning when i go out of bed, so it will never start if i am not home and no motion is present, so about you what is better to trigger?
I checked also the device_tracker and it was home in that hours… so i was home and the motion was off, but the automation started!
There is no ‘better way’ it should be what you want. If you aren’t home will your motion detector detect motion? If the answer is ‘no’, then just remove the at home trigger. If the answer is ‘yes’, add a condition requiring you to be at home.
You may have been home, but you can go from an on state to an on state. That’s partly why state triggers have a from and to attribute.
Yes, i need to be home as i want it starts only if I am home. SO i need to add a from state and a to state in the code?
No, I’ve described what you need to do 2 times already. You need to move your at home trigger to a condition and properly format it.