I am using input_datetime to select a time from a list of values. The selected value sets the state of entity “input_select.stoveamstart” to a given time.
What I would like to achieve, is that whenever the state of entity “input_select.stoveamstart” changes, it’s value is written into the state of another entity: “input_datetime.stove_morning_start”.
I use the values in input_datetime.stove_xxxxx_xxxxx as conditions in my automations, to turn the stove on and off based on time of day (as well as inputs from temperature sensors).
However, as easy as this must be, I cannot get it to work.
Here is my latest iteration of code. Any ideas? Should be a simple one!
But I wonder, @nealedowling, why are you bothering to transfer the value from input_select.stoveamstart to input_datetime.stove_morning_start? Why not just use input_select.stoveamstart directly (wherever it is you’re using input_datetime.stove_morning_start?) Both entities will have exactly the same state (which is just a string.) Maybe you’re using the timestamp attribute???
Thank you. Got it working.
You ask a very good question. I will need to review my code. I’m not an experienced coder (could you guess? ha!) and I think I got myself confused.
I will clean this up as I clearly don’t need both.
EDIT: The reason for having two entities just came back to me: The input_select allows me to input a time from a list of values in the front end. However, I have an automation that sets the time based on a calendar entry less 1 hour 45 minutes. As this calculation can be outside of the range of values, I want to cover that, but want to ensure the selection list in the front end does not get polluted with lots of different values. So the input_select is just used for inputs, the input_datetime.stove_morning_start is used for templates and automation trigger etc.
I’m trying to take the value of my ‘sensor.electric_consumption_today’ at 23:59 and set the value of another sensor; ‘sensor.electricity_consumption_yesterday’ at 00:01 the next day to this value.
I have searched for parsing states but I’m not finding anything that makes sense to me (noob at yaml) but I did put together the following in an attempt to at least parse the value from one to the others, but using the Developer tools templates checker, it only parses a value of 0.0 which is the value of ‘sensor.electricity_consumption_yesterday’ as it currently is after the {% else %} statement.
- platform: template
sensors:
sensor.electricity_consumption_yesterday:
friendly_name: electricity_consumption_yesterday
value_template: >
{% set value = states.sensor.electric_consumption_today.attributes %}
{% if value.electric_consumption_today is defined %}
{{ value.electricity_consumption_yesterday }}
{% else %}
{{ states('sensor.electricity_consumption_yesterday') }}
{% endif %}
Would anyone be able to assist me to correct this to state the value from the ‘sensor.electric_consumption_today’ and also at the required times for the parse to take place?
Developer Tools output of the above attempt:
It should be reading the ‘sensor.electric_consumption_today’ but I obviously dont have the correct syntax.