I am trying to take the attribute date stored under the term Next Start
Next start April 5, 2025 at 23:30:00
but only use the data after “at”
This will be generated into a sensor so that I can then use it as a When time is equal to (in this case 23:30) then stop automation.
Having read the forums I tried this:
- sensor:
- name: "Octopus dispatch next"
state: >
{{ state_attr('binary_sensor.octopus_energy_a_REDACTED_intelligent_dispatching', 'Next start') | split('t')[1] }} # Split by letter t, get the second part
unit_of_measurement: "timestamp"
device_class: "timestamp"
state_class: "Measurement"
Invalid config for 'template' at configuration.yaml, line 70: invalid template (TemplateSyntaxError: expected token 'end of print statement', got '[') for dictionary value 'sensor->0->state', got "{{ state_attr('binary_sensor.octopus_energy_a_REDACTED_intelligent_dispatching', 'Next start') | split('at')[1] }} # Split by letter t, get the second part\n"
Invalid config for 'template' at configuration.yaml, line 72: invalid template (TemplateSyntaxError: expected token 'end of print statement', got '[') for dictionary value 'sensor->0->state', got "{{ state_attr('binary_sensor.octopus_energy_a_REDACTED_intelligent_dispatching', 'Next start') | split('at')[1] }} \n"
Sorry, but I can only answer what I am able to. I am asking for help because I do not totally understand.
The movement forward has been I have been able to get the sensor to work by changing the next start to next_start
State is the state of the actions you asked me to perform or otherwise the output from them.
I.e the output states that……
You are correct there is no at in the raw data output but there is in The attributes shown in the user interface (I assume that is what it is called).
So now in the raw data it shows as a date code space and then time. So I just need to work out how to only get the time without the +etc
Thanks for getting me this far… just a shame that you have not understood my replies and that equally i have not seen all your changes as you have not coached me in what you have done but instead thrown useful coding back.
I am very pleased with what you have done, just a pity you are not with my replies. Maybe I can learn from that.