I have created the sensor:
For everyone that comes googling for this:
configuration.yaml
sensor:
- platform: template
sensors:
rova_bio_adjusted:
value_template: "{{ (states('sensor.rova_bio') | as_datetime - timedelta(hours=12)).isoformat() }}"
device_class: timestamp
In the automation under trigger:
But why does it say No matching entities found? it;s not a typo.
in YAML it looks like:
platform: time
at: sensor.rova_bio_adjusted
So will this trigger type as time with this sensor be triggered?
123
(Taras)
September 29, 2021, 5:38pm
10
Look at what you selected “Value of a date/time helper ”. It only lists input_datetime
entities.
Basically, you have discovered one of the Automation Editor’s several deficiencies, in this case it lacks the means of selecting a timestamp sensor even though that’s a valid choice for a Time Trigger. You have to switch to YAML mode and manually enter the sensor’s entity_id
.
On a separate note, the Template Sensor configuration you posted is unformatted. Here’s the formatted version:
sensor:
- platform: template
sensors:
rova_bio_adjusted:
friendly_name: Rova Bio Adjusted
value_template: "{{ (states('sensor.rova_bio') | as_datetime - timedelta(hours=12)).isoformat() }}"
device_class: timestamp
The equivalent using the new way of defining Template Sensors is like this:
template:
- sensor:
- name: Rova Bio Adjusted
state: "{{ (states('sensor.rova_bio') | as_datetime - timedelta(hours=12)).isoformat() }}"
device_class: timestamp
I have adjusted my previous post, now with preformatted text.
123
(Taras)
September 29, 2021, 7:01pm
12
Remove the backquote character after the word timestamp
Done, thanks for the help and advice!
123
(Taras)
September 29, 2021, 7:37pm
14
You’re welcome!
Please consider marking my post (above) with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. It will also place a link below your first post that leads to the solution post. All of this helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.
The timestamp adjustment works, it shows the correct date.
But the automation didn’t trigger at this date:
In visual editor:
In YAML:
There are no other triggers for this, and no conditions,
So why is this automation not triggering?
The automation should have triggered at 4th october mid day, (as this is shown by the “sensor.rova_residual_adjusted”
123
(Taras)
October 5, 2021, 1:49pm
16
Post the state
value of sensor.rova_bio_adjusted
exactly as it appears in Developer Tools > States.
State is :2021-10-11T12:00:00
State attributes (YAML, optional):
friendly_name: rova_bio_adjusted
device_class: timestamp
(it’s no longet the date from the 4th of october, now its the next pickup)
123
(Taras)
October 5, 2021, 2:18pm
18
It lacks a timezone offset so that might be the reason it fails to qualify as a proper timestamp sensor for use with a Time Trigger.
Let’s add your timezone offset and see if it fixes the problem.
Change the Template Sensor’s template to this:
sensor:
- platform: template
sensors:
rova_bio_adjusted:
friendly_name: Rova Bio Adjusted
value_template: "{{ (states('sensor.rova_bio') | as_datetime - timedelta(hours=12)).astimezone().isoformat() }}"
device_class: timestamp
When you are done and have reloaded template entities, post the sensor’s new state
value so we confirm it now has a timezone offset.
I have made the change as describted above, hope it works!
123
(Taras)
October 5, 2021, 5:00pm
20
frank8the9tank:
hope it works!
Me too. I created a version of it for myself that should trigger tomorrow at noon. I’ll let you know if it works.
123
(Taras)
October 7, 2021, 12:45am
21
FYI, the version I created triggered at noon today. I have reset it to trigger again tomorrow. I’m confident it will work again tomorrow for me and for you on October 11th.
Sounds good, for me i have a next pickup date in 5 days, will let know the result,
If all okay, i will mark it as the solution.
It works, i can the notification trought the telegram service,
Marked the post as the solution, .astimezone() did the trick,
many thanks.
1 Like
I’m still to stupid.
In Nodered and Json, I succeeded already to concatenate some values from different “payload messages”
Like:
let num7 = msg.payload7;
Now I want to add the timestamp of the message in a readable format
I tried already several examples but I’ve always an error:
Like: let time = msg.payload7.timestamp;
Gves a “tim undefined” answer in debug screen
How can I extract thedate and the time from a message?
n1k5y
(Nikola)
February 4, 2022, 12:41pm
25
Timestamp of what? and what you need to do with it? What you tried? Give more info
n1k5y
(Nikola)
February 4, 2022, 12:59pm
27
For simple way you can use
var textdate=new Date(msg.payload).toISOString().replace(/\..+/,'');
or for custom display based on Date - JavaScript | MDN
Thank you.
I still have to learn a lot.
I have already the date & time in my string, concatenated with other values.
In my function object, I’m returning the string :
msg.payload = ans;
return msg;
And the string shows up correctly in the debug screen.
But how can I send this string in a notify object
My notify/email functions correctly, but when sending a text message.
Now I want to send the string I made in the function.
This does not work :
How can I send the output of my function?
n1k5y
(Nikola)
February 4, 2022, 3:21pm
29
In json type something as
{
"title":"Temp",
"data":{ "message": msg.payload}
}
If it’s not exact I can check later in nodered, I am not at computer currently.