{% from 'easy_time.jinja' import custom_time %} {% macro timer_duration(input_number) %} {{ (states(input_number)) | int * 60 }} {% endmacro %} {% macro current_time(hr) %} {% if hr == 12 %} {{ now().strftime('%-I:%M %p') }} {% elif hr == 24 %} {{ now().strftime('%H:%M') }} {% endif %} {% endmacro %} {% macro current_date_input() %} {{ now().strftime('%Y-%m-%d') }} {% endmacro %} {% macro input_datetime_read(entity,type) %} {% if type is defined %} {% if type == 'withdate' %} {{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p') }} {% elif type == 'nodate' %} {{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p', False) }} {% endif %} {% else %} {{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p', False) }} {% endif %} {% endmacro %} {% macro current_date_readout() %} {{ states('sensor.today_is') }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }} {% endmacro %} {% macro calendar_event_today(calendar) %} {% if state_attr(calendar,'start_time') %} {{ as_timestamp(strptime(state_attr(calendar,'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%Y-%m-%d") == now().strftime("%Y-%m-%d") }} {% endif %} {% endmacro %} {% macro time_from_calendar(calendar,start_or_end,action) %} {% if action == 'set' %} {{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }} {% elif action == 'read' %} {{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%-I:%M %p") }} {% endif %} {% endmacro %} {% macro set_datetime(hours,minutes,seconds) %} {% if seconds is defined %} {{ (as_timestamp(now()) + (((hours * 60) * 60) + (minutes * 60)) + seconds) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }} {% elif minutes is defined %} {{ (as_timestamp(now()) + ((hours * 60) * 60) + (minutes * 60)) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }} {% else %} {{ (as_timestamp(now()) + (hours* 60) * 60) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }} {% endif %} {% endmacro %} {% macro ct() %} {{ ((now().hour * 60 + now().minute) * 60 ) }} {% endmacro %} {% macro next_twitch_stream() %} {{ custom_time('calendar.tony_s_twitch_schedule','week,day,hour') }} {% endmacro %}