I had to add two triggers for the case that heat/cool required is already true when the on times roll around and also put my extra temperature conditions back in for this.
Also the condition you added in the action section is not required as this is taken care of in the following template sensors:
- platform: template
sensors:
lounge_ac_am_automation_time_active:
friendly_name: "Lounge AM Automation Time Active"
entity_id:
- sensor.time # required to update now()
- input_datetime.lounge_ac_am_on_time
- input_datetime.lounge_ac_am_off_time
- input_boolean.lounge_ac_am_automation
value_template: >-
{% set d = now().strftime("%Y-%m-%d ") %}
{% set t = now().timestamp() %}
{% set am_start = strptime(d + states('input_datetime.lounge_ac_am_on_time'), '%Y-%m-%d %H:%M:%S').timestamp() %}
{% set am_end = strptime(d + states('input_datetime.lounge_ac_am_off_time'), '%Y-%m-%d %H:%M:%S').timestamp() %}
{{ (am_start <= t <= am_end) and is_state('input_boolean.lounge_ac_am_automation', 'on') }}
lounge_ac_pm_automation_time_active:
friendly_name: "Lounge PM Automation Time Active"
entity_id:
- sensor.time # required to update now()
- input_datetime.lounge_ac_pm_on_time
- input_datetime.lounge_ac_pm_off_time
- input_boolean.lounge_ac_pm_automation
value_template: >-
{% set d = now().strftime("%Y-%m-%d ") %}
{% set t = now().timestamp() %}
{% set pm_start = strptime(d + states('input_datetime.lounge_ac_pm_on_time'), '%Y-%m-%d %H:%M:%S').timestamp() %}
{% set pm_end = strptime(d + states('input_datetime.lounge_ac_pm_off_time'), '%Y-%m-%d %H:%M:%S').timestamp() %}
{{ (pm_start <= t <= pm_end) and is_state('input_boolean.lounge_ac_pm_automation', 'on') }}
In the front end the sensors change from :
to
Exactly when they should.
However this automation never fires:
- id: lounge_aircon_auto_off
alias: 'Lounge Room Aircon Scheduled Off'
trigger:
- platform: state # AM or PM off time trigger
entity_id:
- binary_sensor.lounge_ac_am_automation_time_active
- binary_sensor.lounge_ac_pm_automation_time_active
to: 'off'
condition:
- condition: template # Only if AC is on
value_template: "{{ not is_state('input_select.lounge_ac_mode.state', 'Off') }}"
- condition: or # And only if workday not tested or if workday
conditions:
- condition: state
entity_id: input_boolean.lounge_ac_workday
state: 'off'
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
action:
- service: input_select.select_option
data_template:
entity_id: input_select.lounge_ac_mode
option: 'Off'
Looking at the template editor I see this before the event:
I see the same thing. The state changes in the front end and the template editor exactly when it should but the automation never fires.
The reason I’m using template sensors is because I have to trigger on or test this condition in multiple automations and it does not seem efficient to keep having to write the long hand templates everywhere.
Excellent suggestion. Why didn’t I look there? I l only looked at the error log.
The automation is actually firing according to the log book. However my AC is not changing state when the input_select that controls it changes state… Hardware problem perhaps?
I logged into the web interface for the device that controls the AC unit - I can control it fine. So not that.
Oh bugger! I accidentally deleted the automation that manually controls the AC unit via an input_select when tidying up all the time/temperature automations.
Nope, either are fine. Personally, I avoid using states.domain.entity.attributes.attr. Only because of startup issues and errors when those devices haven’t been created. If you use state_attr('domain.entity','attr') your templates will return results at all times if you convert them to the proper type. I.E. state_attr('domain.entity','attr') | int will convert the result to 0 if domain.entity doesn’t exist yet. Then your template will still resolve to a false/off state and no errors will be produced in the logs.
I think the sensors themselves, that together make up the Mold indicator. see the log:
2018-09-18 23:32:00 ERROR (SyncWorker_3) [homeassistant.components.sensor.mold_indicator] Unable to parse sensor temperature: unknown
2018-09-18 23:32:00 ERROR (SyncWorker_18) [homeassistant.components.sensor.mold_indicator] Unable to parse sensor humidity: unknown
2018-09-18 23:32:02 ERROR (MainThread) [homeassistant.components.sensor.statistics] mean requires at least one data point
2018-09-18 23:32:02 ERROR (MainThread) [homeassistant.components.sensor.statistics] variance requires at least two data points
2018-09-18 23:32:02 ERROR (MainThread) [homeassistant.components.sensor.statistics] variance requires at least two data points
tha last 3 lines are from a statistics sensor, that apparently isnt initialized yet either.
and, an ever returning error:
2018-09-18 23:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
TypeError: update() takes 1 positional argument but 2 were given
2018-09-18 23:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
TypeError: update() takes 1 positional argument but 2 were given
2018-09-18 23:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
TypeError: update() takes 1 positional argument but 2 were given
2018-09-18 23:35:54 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
result = method(*args, **kwargs)
TypeError: update() takes 1 positional argument but 2 were given
No idea where and how to start looking for that one…
I see start up mold sensor these errors too. Unfortunately that’s not something we have control over (as it is the component itself that has start up dependency problems).
Yeah, it doesn’t look like this is normal startup errors related to templates. What’s odd about these errors is that it doesn’t appear to come from the mold indicator. Have you turned on debug logging to view what the component is outputting?
No not yet. did that before once, and it almost halted my system… Other than setting debug globally, could I set it to a separate component, based on this log output?
As soon as HA is started The heat or cool required template sensors are in the wrong state. Probably because the zwave sensor they rely on has not initialised yet.
I attempted to mitigate this with a “glitch_delay” sensor set as the first action in a start up automation. Unfortunately it was not fast enough to prevent the incorrect sate triggering the AC unit.
If I could access a HA start timestamp. I could prevent the AC automation running until 5 seconds or so after start up. Is there one?
Something like:
condition: state
entity_id: homeasistant?
state: on
for:
seconds: 5
Edit: maybe this,
sensor:
- platform: uptime
Edit 2: or maybe add a time to the heat required condition: