elden1337 / hass-peaqnext

Utility sensors to help find the next best usage of your appliances
Other
7 stars 0 forks source link

Possible to get a sensor with just the datetime #16

Closed mariwing closed 1 year ago

mariwing commented 1 year ago

Hi, this is a cool component - thanks for your work!

I have both a dishwasher and a washing machine that is controllable from Home Assistant so what I would like to do is set the timed start on my appliances to the time your great component suggests as the best time. The sensor now shows start time, end time and cost as a string (which is fine for display in Home Assistant frontend). But for automation purposes it would be great to have the suggested start time available as a seperate sensor in a "Home Assistant approved" datetime format. Having such a sensor would avoid having to parse and jinja template to get the time. Instead the sensor could be used directly.

elden1337 commented 1 year ago

No prob. will add a raw-attribute if that's ok with you? I just have to read up on what strftime-formatting is needed.

elden1337 commented 1 year ago

as per the templating, the set attribute "raw_start" should work fine:

{{ as_timestamp(state_attr("sensor.peaqnext_diskmaskin", "raw_start")) | timestamp_local }} == 2023-08-07T23:04:00+02:00
{{ as_timestamp(state_attr("sensor.peaqnext_diskmaskin", "raw_start"))}} == 1691442240.0
{{ state_attr("sensor.peaqnext_diskmaskin", "raw_start")}} == 2023-08-07T23:04:00.000000

will add to the release just now.

mariwing commented 1 year ago

Awesome!

man. 7. aug. 2023 kl. 22:39 skrev Magnus Eldén @.***>:

No prob. will add a raw-attribute if that's ok with you? I just have to read up on what strftime-formatting is needed.

— Reply to this email directly, view it on GitHub https://github.com/elden1337/hass-peaqnext/issues/16#issuecomment-1668548768, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNMQOJMVED7XP2NRPBLYPTXUFHA7ANCNFSM6AAAAAA3HPWXH4 . You are receiving this because you authored the thread.Message ID: @.***>