GeorgeSG / lovelace-time-picker-card

🕰️ Time Picker Card for Home Assistant's Lovelace UI
MIT License
209 stars 14 forks source link

Sensor with time-picker-card data formatted without seconds. #17

Closed SdeGeata closed 3 years ago

SdeGeata commented 3 years ago

Hello George;

Great work on the card! I just installed it and love it!

I am trying to make a sensor to filter the data produced by the time-picker-card to shave off the seconds characters from the string to send to an LCD display. I can't seem to add the input_datetime as a sensor on the LCD as it is a string and handles it better as text, but this adds 3 extra characters to my output on the LCD that I really don't need, ":00". I could use the extra character space on the display.

I have been researching time template sensors on Home Assistant, but I am not really trying to do a calculation from current time, I am trying to use the numbers input by your picker. How can I do this???

GeorgeSG commented 3 years ago

Hey @SdeGeata,

If I understand correctly, you need the template syntax for getting the value of your input_datetime without the seconds.

Try this:

{{ states('input_datetime.input_name')[0:-3] }}

You should be able to use this in a template sensor.

Edit: btw, this has nothing to do with Time Picker Card - that's native Home Assistant functionality/behavior.

SdeGeata commented 3 years ago

Hello! Thanks for your reply!

I ended up finding {{ states("input_datetime.input_name")[:5] }} late last night, that seems to do the job. I'm not sure how it works, nor how your suggestion works. I will try yours out too.

Keep up the good work!

GeorgeSG commented 3 years ago

@SdeGeata

Thanks!

In short, {{ states("input_datetime.input_name") }} returns the value of your datetime input, so it will be something like "18:16:00" (depending on what value you have set), then [:5] is the python syntax for "get just the first 5 symbols". My suggestion - [0:-3] is the python syntax for "drop the last three symbols". Both will result in "18:16". Hope this helps :)

SdeGeata commented 3 years ago

Ah, that makes more sense. Thanks for the lesson!

Take care.

@.***?Subject=%C2%A1s%C7%9D%C4%B1%C9%B9%C7%9D%C9%90%C9%9F%20%C7%9D%C9%A5%CA%87%20%C9%A5%CA%87%C4%B1%CA%8D%20%CA%8E%C9%90%CA%8D%C9%90>  
}=={======> From the Desk of Stiofán of the de Geata Clan.

Sword Swallower • Fire Eater • Deck Hand • Roustabout • Carpenter • Sculptor • Molder • Welder • Green Man • Mushroom Hunter • Brewer • Baker • Camel Whisperer • Mead Ninja • Psychonaut • Student of Life • Modern-day Druid • Roaming Gnome

Montréal, Québec. @. @.?Subject=%C2%A1s%C7%9D%C4%B1%C9%B9%C7%9D%C9%90%C9%9F%20%C7%9D%C9%A5%CA%87%20%C9%A5%CA%87%C4%B1%CA%8D%20%CA%8E%C9%90%CA%8D%C9%90> Sword Swallower • Fire Eater • Deck Hand • Roustabout • Carpenter • Sculptor • Molder • Welder • Green Man • Mushroom Hunter • Brewer • Baker • Camel Whisperer • Mead Ninja • Psychonaut • Student of Life • Modern-day Druid • Roaming Gnome @.***?Subject=%C2%A1s%C7%9D%C4%B1%C9%B9%C7%9D%C9%90%C9%9F%20%C7%9D%C9%A5%CA%87%20%C9%A5%CA%87%C4%B1%CA%8D%20%CA%8E%C9%90%CA%8D%C9%90>

Montréal, Québec. @. @.?Subject=%C2%A1s%C7%9D%C4%B1%C9%B9%C7%9D%C9%90%C9%9F%20%C7%9D%C9%A5%CA%87%20%C9%A5%CA%87%C4%B1%CA%8D%20%CA%8E%C9%90%CA%8D%C9%90> @.> @.> <skype:I_betyar?userinfo>

  This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately.

Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. Si ce message vous a été transmis par erreur, veuillez en informer l'expéditeur et le supprimer immédiatement. https://www.facebook.com/stiofan.degeata

This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately.

Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. Si ce message vous a été transmis par erreur, veuillez en informer l'expéditeur et le supprimer immédiatement. https://www.facebook.com/stiofan.degeata

On Mar 18, 2021, at 12:18 PM, Georgi Gardev @.***> wrote:

@SdeGeata https://github.com/SdeGeata Thanks!

In short, {{ states("input_datetime.input_name") }} returns the value of your datetime input, so it will be something like "18:16:00" (depending on what value you have set), then [:5] is the python syntax for "get just the first 5 symbols". My suggestion is the python syntax for "drop the last three symbols". Both will result in "18:16". Hope this helps :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GeorgeSG/lovelace-time-picker-card/issues/17#issuecomment-802060773, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMKFZ275IZGY5LTHKLD6MTTEIRUFANCNFSM4ZLS4X6Q.