I use a helper to convert computer time to human time.
This then means I can adjust the time to the inverter using HA helper time.
But it does not reciprocate if the time is adjusted on the inverter website.
I was thinking of writing something like:
If helper time last update is before inverter(computer time) then update helper time with equation… else stop with reason - does not match condition.
Can anyone help me,
I have looked in the scripts in the UI but can’t see anything like it.
Sorry this isn’t about real time this is about schedule timings for
AC charge
AC only power.
So if I set the schedule in HA it transfers it to inverter no problem.
But is I set it in inverter, it transfers it to HA in computer speak but then does not update the helper to ye human speak.
okay, I am all new to the technical jargon and learning as I go. The inverter sends the time to the HA as a series of digits, is this called unix time?
My current automation allows me to type the time for change into a 12 hour notation and then it calculates this and sends it to the inverter in Unix time. This all works well.
However, if a change is made in the inverter, the time is still sent over in Unix time to HA but there is no automation to then update the helper to 12 hour time.
This is what I need help with
BUT:
It will need a condition to stop it combating with the existing automation that is sending the changes in the 12 hour clock helper back tot he inverter, as this will then trigger the above and we will have an infinite loop.
That is wher eI though something like If then else would have it compare the last update time of the unix time with the update time of the 12 hour human time and decide if it should action.
Stumbling block I am having is:
a) I don’t know how to extract the last update time I can see in the history to allow me to work with it.
b) I don’t know how to lift the value from the unix time and convert it.
original entity ------------------------------->Friendly clock helper entity
number.lux_ac_charge_end relates to Lux- AC Charge End 1
number.lux_ac_charge_end1 relates to Lux- AC Charge End 2
number.lux_ac_charge_end2 relates to Lux- AC Charge End 3
trigger:
- platform: state
entity_id:
- input_datetime.lux_ac_charge_end_2
variables:
inputDatetimeEntity: input_datetime.lux_ac_charge_end_2
outputEntity: number.lux_ac_charge_end1
condition: []
action:
- service: number.set_value
data_template:
value: >-
{{ state_attr(inputDatetimeEntity, 'minute')|int * 256 +
state_attr(inputDatetimeEntity, 'hour') | int }}
entity_id: number.lux_ac_charge_end1
mode: single
id: '1659465742926'
alias: Lux- AC Charge End 2
description: ''`
It won’t set the number entity if its existing value is already the same as the value of the input_datetime entity. That’s what the addition of the Template Condition does (the rest of the automation is essentially unchanged except for some streamlining).
But will it work bothways. So if the inverter sends the time then it will update the helper and if the helper sends the time it will update the inverter?
The automation you posted performs only one function, if the input_number changes it updates the number (what I added was to restrict its behavior; update the number only if the number’s existing value isn’t the same as the input_datetime).
Unless you have another automation that performs that function, the automation you posted doesn’t do that.
I suppose I need it to compare the date stamp of the two entries and choose the correct one and populate the other side. e.g. if it is the 12 hour clock that has the latest entry, change the UNIX clock or vice versa! Not asking much am I!
Yip and I obviously never explained myself clearly enough. The other automaton (the other way round is what I am after but not then having an infinite loop when it starts)
Clearly being thick here but if both automations are running, how does either know what is the most recent input, the 12 hour clock input or the unix input?
Surely the condition just says, if it is the same leave it, if it is different change it. But that could mean it changing it back to the old way? or will it trigger the correct automation as soon as a change is detected so not overwriting the wrong wayu round?- Again I am new to this so please excuse the idiocy.
So the automation compares the UNIX to the human 12 hour if the UNIX is wrong then it corrects it from the 12 hour time.
This is fine if the 12 hour time has been adjusted - Lets call this automation 1
So the automation compares the UNIX to the human 12 hour, on this occasion as the UNIX has been changed from the inverter it will be the correct time but automation 1 will discount this and force back to the 12 hour.
The only way i can see around this is either comparing change times from the logs or having the two automations (1 being as described above and the second being for scenario 2 but forcing 12 hour clock change) but how would one out win the other, is there a way to trigger based on changed values?
How does the automation know the supplied time is “wrong”? What is the source of truth for the time?
For example, the posted automation (above) simply sets number if input_datetime changes to a different value. It has no concept of which value is wrong/right, it just detects a difference between the two values.
There are two scenarios for the source of the truth.
One being directly from the inverter
One being from manual input in the 12 hour time helper.
These are the two scenarios of input.
That is why I need the automation to compare what data is the most up to date sent to the HA so that the truth is used.
When I look at the log history for the AC charge (UNIX TIME) end it shows it has been updated today at 11.00 and the 12 hour helper has never been updated. In this scenario I would want the Unix time to be the truth and change the 12 hour time.
But if the 12 hour helper was updated by the user then this would have the most up to date changed log and this would be compared with the UNIX time and the truth would be the 12 hour helper (As this automation above is doing at the moment).