You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This video was done on basis of the input request done here. I hope other people can use it for something. If you're normally trying to skip the string-manipulation in JavaScript, maybe this is a good place for you to start.
Learn how to get a "timestamp"-entity state in JavaScript, combine it with a date, and format the timestamp to your needs. We'll use the text_set ha-floorplan service, the new Date() JavaScript object, and our util function to format it. There's also a few times on howe to use console.log, and other small things like creating a one-line expression, rather than a four liner. I'll also point how, how to "use" the "format string" for the strftime util-function.
I hot-reload my YAML-changes on the way. In the attached files (see the top of the description), you're able to see how that's implemented in the SVG, and with the use of browser_mod.
Software used:
➡️ Home Assistant 2023.3.3
➡️ Firefox Developer Edition 111 (64-bit)
➡️ Visual Studio Code installed as a add-on in Home Assistant OS
➡️ The "Google Theme" for Home Assistant, modded for mostly all-black backgrounds.
🗣️💬 Your feedback
Hi. Thank you for looking by this video.
Please let me know what you think, and press the like button!
Changes to this video: Yet again, a new microphone is in use. This time, I ordered a brand new professional microphone, to give you the best experience. I really hope you enjoyed the overall improvement. I've tried to cut out zoom and focus-blur, and instead, using my cursor, and secure proper sized text on my screen. Let me know what you think? I'd like to point out that I'm still playing around with the position of the mic, to prevent too-much keyword-press sounds in the video - I'm not there, yet.
Home Assistant is known to change over time, so things can be outdated quite fast. I hope most things will be stay the same... But let's see how it goes!
Tags:
home assistant, home assistant os, yaml, visual studio code, new Date(), javascript, format date, date, strftime, ha-floorplan, entity state, console.log, floorpan, svg, manipulate date, military, am/pm timestamp
Video chapters:
00:00 Introduction
00:22 Visual overview of the key-points in the video
00:54 Topics in the video
01:43 Details about the time_state sensor
02:20 Define service data keys with JavaScript
02:30 console.log your entity for debugging purpose
02:55 Prepare our new date string
03:20 Use new Date() to parse the string as a JavaScript Date-object
03:37 Using console.log to validate our new Date-object called dateTimeParsed
03:58 Use the strftime util-function for format the newly created Date-object
04:40 Validate that everything work as expected
04:50 Find the definition of the format-string for strftime on Google
05:15 Short version of the solution (single line of code)
06:04 Remember the docs
06:14 Checkout our discussion area
06:45 Outro with a spoiler about the future
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This video was done on basis of the input request done here. I hope other people can use it for something. If you're normally trying to skip the string-manipulation in JavaScript, maybe this is a good place for you to start.
Happy watching 😄!
https://www.youtube.com/watch?v=GHcgwW-OOo8
Description from YouTube:
📁 Attachments: https://github.com/exetico/Home-Assistant_Attachments-for-YouTube/tree/main/6_Format-time_date.time-entity-from-military-to-AM_PM-in-state_action
Learn how to get a "timestamp"-entity state in JavaScript, combine it with a date, and format the timestamp to your needs. We'll use the text_set ha-floorplan service, the new Date() JavaScript object, and our util function to format it. There's also a few times on howe to use console.log, and other small things like creating a one-line expression, rather than a four liner. I'll also point how, how to "use" the "format string" for the strftime util-function.
I hot-reload my YAML-changes on the way. In the attached files (see the top of the description), you're able to see how that's implemented in the SVG, and with the use of browser_mod.
Are you interested in my Hass.io code-setup? Checkout 📺: https://youtu.be/7AU5i-WUUxw
❤️☕ Support my work:
https://www.buymeacoffee.com/coffeetoexetico
Software used:
➡️ Home Assistant 2023.3.3
➡️ Firefox Developer Edition 111 (64-bit)
➡️ Visual Studio Code installed as a add-on in Home Assistant OS
➡️ The "Google Theme" for Home Assistant, modded for mostly all-black backgrounds.
🏆 ha-floorplan
Documentation: https://experiencelovelace.github.io/ha-floorplan
GitHub: https://github.com/ExperienceLovelace/ha-floorplan
Examples source-code: https://github.com/ExperienceLovelace/ha-floorplan/tree/master/docs/_docs/floorplan/examples
🗣️💬 Your feedback
Hi. Thank you for looking by this video.
Please let me know what you think, and press the like button!
Changes to this video: Yet again, a new microphone is in use. This time, I ordered a brand new professional microphone, to give you the best experience. I really hope you enjoyed the overall improvement. I've tried to cut out zoom and focus-blur, and instead, using my cursor, and secure proper sized text on my screen. Let me know what you think? I'd like to point out that I'm still playing around with the position of the mic, to prevent too-much keyword-press sounds in the video - I'm not there, yet.
Home Assistant is known to change over time, so things can be outdated quite fast. I hope most things will be stay the same... But let's see how it goes!
Tags:
home assistant, home assistant os, yaml, visual studio code, new Date(), javascript, format date, date, strftime, ha-floorplan, entity state, console.log, floorpan, svg, manipulate date, military, am/pm timestamp
Video chapters:
00:00 Introduction
00:22 Visual overview of the key-points in the video
00:54 Topics in the video
01:43 Details about the time_state sensor
02:20 Define service data keys with JavaScript
02:30 console.log your entity for debugging purpose
02:55 Prepare our new date string
03:20 Use new Date() to parse the string as a JavaScript Date-object
03:37 Using console.log to validate our new Date-object called dateTimeParsed
03:58 Use the strftime util-function for format the newly created Date-object
04:40 Validate that everything work as expected
04:50 Find the definition of the format-string for strftime on Google
05:15 Short version of the solution (single line of code)
06:04 Remember the docs
06:14 Checkout our discussion area
06:45 Outro with a spoiler about the future
Beta Was this translation helpful? Give feedback.
All reactions