Hello Star Trek fans! I have created an entity that displays the current Stardate, and I thought I would share it.
The math for this was sourced from TrekGuide.com =/\= Calculating Stardates and Calendar Dates, and displays the Stardate of the current TNG Star Trek episode or movie to represent today’s Stardate (i.e. the Stardate of this week’s episode if The Next Generation and its spinoffs were still in production). There are other Stardate systems described there, but this is the one I chose.
This calculation depends on the ‘date_time_iso’ sensor. If you have not already added it to your configuration.yaml (like say, when you installed the LCARS theme), you will need to add it as below. I only use the ‘date_time_iso’ display option, but it wont hurt to add the rest.
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_utc'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
Once that is added, we need to create a Template Helper that will do the math:
Settings → Devices & Services → Helpers → Create Helper → Template → Template a Sensor → State Template:
{{ (((as_timestamp(states('sensor.date_time_iso')) - (as_timestamp("1987-07-15 00:00:00"))) // 3155.76 ) + 410000 ) / 10 }}
Name this “Stardate”, and you are done! The Stardate can be easily added to an Entity card, or wherever else you like.
If you have improvements, or want to do the math for other Stardate calculations, please share them! Thanks
EDIT: Removed deprecated ‘beat’ from display options