#Sensor: Get time from entity

87 messages · Page 1 of 1 (latest)

thick meadow
#

Hello, I am trying to do a wakeup-light using a blueprint. To change the wakeup-time on the dashboard I can use a sensor inside the blueprint. Now I want to use an entity whose value for the time I can change on the dashboard that writes its value to the sensor.
I tried to write something in the configuration.yaml, but its not working.

template:

  • sensor: WakeUp Light Timestamp
    device_class: timestamp
    xxxx ?
ornate anchor
#

Why not just use a date time helper and use that entity in your blueprint?

Are you trying to add an additional attribute to your sensor?

thick meadow
#

The blueprint only accepts sensors

#

no, not an additional attriute

ornate anchor
#

What blueprint is it?

thick meadow
#
#

this line

ornate anchor
#

Ahhhh gotcha. Yeah I see it. 1 sec.

#

So, the way that I am trying to do it just doesn't seem to want to work right. I tried creating a template taking the state of an input date/time helper and converting it to a timestamp device_class class and it doesn't want to do that.

#

BUT, you can take control of the blueprint and just remove line 21 from it and then you can use an input_datetime helper there.

thick meadow
#

oh ok let me see

#

so it's this i guess

ornate anchor
#

Hmmmm, no

thick meadow
#

I need to change line 22 from sensor to entity?

ornate anchor
#

No, share the YAML you have using dpaste.org (or other code sharing site)

#

That code is fine.

crystal light
#

I think you have to massage a time helper a little bit to make it into a timestamp, the state itself is not any kind of ISO valid time string, very simplified

#

oh but I think the attributes contain a real timestamp?

ornate anchor
#

Oh you're right. I think there is a timestamp attribute. 1 sec.

crystal light
#

if its a time-only one though you need to add a date to it

thick meadow
#

Oh man... I just want it to be like the following day all the time. Just like a regular alarm clock

ornate anchor
#

Change line 2 to your input_datetime helper.

#

lol I get it.

thick meadow
#

I am confused "light_entity: light.philips_hue_iris_schlafzimmerlicht" is just my hue light

#

this has to stay like this doesnt it?

winter gazelle
#

As a guess - is your input_datetime time only, or have you set it up as time and date?

ornate anchor
#

Typo on my part... line 3 (my bad)

thick meadow
#

Is just a time: Like 14:47 now

crystal light
#

you can't just replace a sensor with an input time, their state format is not the same

thick meadow
#

so just like this: "entity: input_datetime.aufwachzeit_arbeitstag"

#

it worked when i used a if / else part of another user that differentiated between working days and weekends which looked like this:

#

{% if is_state("binary_sensor.input_datetime.aufwachzeit_arbeitstag", "on") %}
{{ today_at(states('input_datetime.aufwachzeit_arbeitstag')) }}
{% elif is_state("binary_sensor.input_datetime.aufwachzeit_arbeitstag", "off") %}
{{ today_at(states('input_datetime.aufwachzeit_sonstige')) }}

#

aufwachzeit_arbeitstag and auchwachzeit_sonstige were both in a helper and i could control that helper

#

but i dont want to separate weekdays and weekends

crystal light
#

ok I think all you need is:

  • input time only datetime helper
  • template sensor with the following:
    {{ today_at(states('input_datetime.test_time')) }}
ornate anchor
#

Would today_at work with a device_class of timestamp though? The blueprint has the selector locked to timestamp entities.

crystal light
#

Yes you can make it a timestamp class

ornate anchor
#

Huh! Ok. That's the piece I was missing with as_timestamp().

thick meadow
#

getting an error?

crystal light
#

that's not how you add a yaml template

thick meadow
#

oh the state-thing is missing?

crystal light
#

yes

thick meadow
#

yeah i also googled that and quickly read a few things. lets see if it works now

#

i got this now, no errors but still not working

crystal light
#

device_class?

thick meadow
#

how to change it?

crystal light
#

your template needs device class, not the datetime helper

#

add it to the yaml that you made

#

or what is not working, specifically

thick meadow
#

ok added the line. Its not turning on the lamp.

#

damn i am confused now

#

1 sec 😄

#

nope that was not the issue 😦 i thought its just the setting in the blueprint

#

what line do I have to change inside the blueprint? line 3 "sensor: none" probably as you said?

#

like only type in "entity: aufwachzeit_arbeitstag" ?

ornate anchor
#

It'll need to be the actual entity name: input_datetime.aufwachzeit_arbeitstag. I'm not 100% sure that will work, tbh.

thick meadow
#

yeah is what I realized too lets see what happens

#

yeah nothing, i dont know... thanks for trying to help. Will have to try out something else I guess

#

need a break now

thick meadow
#

Hey, I solved it with a workaround using this addition in configuration.yaml :

#

I then created 2 helpers which I could integrate into the front screen of HAss

ornate anchor
#

Nice!

thick meadow
#

also, I needed to differentiate between workday and days off with an Integration. If anyone needs help with it, tell me. I followed this video (german, but I can help translate):
https://www.youtube.com/watch?v=X8CxlIV0cIs

Hier zeige ich dir, wie du eine Wake-Up-Light-Automatisierung in Home Assistant erstellen kannst. Lerne, wie du deine Beleuchtung sanft und allmählich erhellen lässt, um auf natürliche Weise aufzuwachen.

Erwecke deine Morgenroutine zu neuem Leben und starte den Tag voller Energie mit dieser einfachen und effektiven Automatisierung. 🙌

Link zur...

▶ Play video
ornate anchor
#

Did you use the workday integration?

thick meadow
#

exactly!

#

Minor downside is: I need to turn it off with a slider if I do not want it to go off, even if it will not be a workday

ornate anchor
#

Soooo, you might also want to create another workday integration that tracks holidays as well. That way, the alarm won't go off when you're off for a holiday. But, that's not perfect if you have to work a holiday.

thick meadow
#

It's already in it!

#

sorry for german, but basically it says you can leave out certain public holidays

#

and you can put in the country you live in and the region

#

the last line is where you can put in your private holiday

#

but as I said: My way is not working like "never go off on holiday", you always have to use the turn-off-slider

#

I think I can live with it to be like that. Has also its advantages.

#

can someone explain to me where this is coming from?

ornate anchor
#

Looks like a chips card left over.

thick meadow
#

Hm so whats the easiest way to get rid of it? Create it all over again from scratch?

ornate anchor
#

You should be able to edit the card. What does the YAML for it look like?

thick meadow
#

that scene schlafmodus is incorrect...

ornate anchor
#

Yup. And that's why you're getting that.

thick meadow
#

ahhhh here we got, its gone

#

ty man