nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
631 stars 41 forks source link

Unexpected trigger even if conditions are not met #246

Closed FedericoBS closed 1 year ago

FedericoBS commented 1 year ago

Checklist

Expected behavior

I scheduled a change of temperature of the conditioner every hour I set up a as trigger 2 conditions in AND related to tracking : PERSON1 IS NOT IN ZONEA; PERSON2 IS NOT IN ZONEA the expected behavior is that if one of the person is in zone the event must not be triggered and the temperature should not change

Actual behavior

Even if Neither condition is met the schedule is triggered. In my example I had set the scheduler to change the temperature of the conditioner every hour if the persons tracked were not at home. The event is triggered and the temperature is changed even if the persons are in zone (i checked the log of the tracker and both persons were constantly inside the zone. it seems that the conditions are checked only when the schedule is turned on

Steps to Reproduce

Here is the schedule:

{ "schedule_id": "185095", "timeslots": [ { "start": "00:00:00", "stop": "02:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 16 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 16 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 16 } } ] }, { "start": "04:00:00", "stop": "05:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 16 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 16 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 16 } } ] }, { "start": "05:00:00", "stop": "06:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "06:00:00", "stop": "07:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "07:00:00", "stop": "08:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "08:00:00", "stop": "09:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "09:00:00", "stop": "10:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "10:00:00", "stop": "11:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "11:00:00", "stop": "12:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "12:00:00", "stop": "13:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "13:00:00", "stop": "14:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "14:00:00", "stop": "15:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "15:00:00", "stop": "16:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] }, { "start": "16:00:00", "stop": "17:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 18 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 18 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 18 } } ] }, { "start": "17:00:00", "stop": "18:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 18 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 18 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 18 } } ] }, { "start": "18:00:00", "stop": "19:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 18 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 18 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 18 } } ] }, { "start": "19:00:00", "stop": "00:00:00", "conditions": [ { "entity_id": "person.federico", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" }, { "entity_id": "person.doina", "attribute": "state", "value": "vicino_a_casa", "match_type": "not" } ], "condition_type": "and", "track_conditions": true, "actions": [ { "service": "climate.set_temperature", "entity_id": "climate.camera_da_letto", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.soggiorno", "service_data": { "hvac_mode": "heat", "temperature": 17 } }, { "service": "climate.set_temperature", "entity_id": "climate.tinello", "service_data": { "hvac_mode": "heat", "temperature": 17 } } ] } ], "weekdays": [ "daily" ], "start_date": null, "end_date": null, "repeat_type": "repeat", "name": "Riscaldamento Federico fuori casa", "enabled": true }

nielsfaber commented 1 year ago

You can enable debug logging by adding this to configuration.yaml:

logger:
  default: warning
  logs:
    custom_components.scheduler: debug

You will need to restart HA afterwards.

After enabling debug logging the scheduler component should add additional lines in the HA logs regarding the checks for the conditions. This should help pinpointing to the issue. Could you please try this and share the results?

nielsfaber commented 1 year ago

Please take note of this issue: https://github.com/nielsfaber/scheduler-component/issues/258

FedericoBS commented 1 year ago

maybe the problem was due to the case sensitivity of the name of the zones as the zone in the condition was coded with an initial upper case letter (see Zone condition is case sensitive nielsfaber/scheduler-component#258). Now the zone and the condition are both in lowercase. I enabled the debug and let you know if the problem persists. tks

edit: when i turn on the schedule the zone conditions are not checked and the action of the schedule are executed:

LOG: 2023-02-14 22:11:15.483 DEBUG (MainThread) [custom_components.scheduler.switch] Schedule 185095 is starting in a timeslot, proceed with actions 2023-02-14 22:11:15.483 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_temperature on entity climate.camera_da_letto 2023-02-14 22:11:15.483 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Postponing next action for 5 seconds 2023-02-14 22:11:15.483 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_temperature on entity climate.soggiorno 2023-02-14 22:11:15.484 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Postponing next action for 5 seconds 2023-02-14 22:11:15.484 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_temperature on entity climate.tinello 2023-02-14 22:11:15.484 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Postponing next action for 5 seconds 2023-02-14 22:11:20.485 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_hvac_mode on entity climate.camera_da_letto 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Action has no effect, skipping 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_temperature on entity climate.camera_da_letto 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Action has no effect, skipping 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_hvac_mode on entity climate.soggiorno 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Action has no effect, skipping 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_temperature on entity climate.soggiorno 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Action has no effect, skipping 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_hvac_mode on entity climate.tinello 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Action has no effect, skipping 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Executing service climate.set_temperature on entity climate.tinello 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Action has no effect, skipping 2023-02-14 22:11:20.486 DEBUG (MainThread) [custom_components.scheduler.actions] [185095]: Finished execution of actions

FedericoBS commented 1 year ago

the problem is solved. I also noticed that if an entity in a condition is a state 'not available', even if it is in OR with other conditions that are met, the action is not executed