From c3731771d9c73865cad9e8777944cd604b2aaec4 Mon Sep 17 00:00:00 2001 From: Tim Ittermann Date: Mon, 8 Apr 2024 09:24:01 +0200 Subject: [PATCH] New Screens --- Resources/screens/_icon_data.sbntxt | 12 ++++++------ Resources/screens/_media_player.sbntxt | 5 +++-- Resources/screens/_timer.sbntxt | 20 ++++++++++++++++++++ Resources/screens/main.sbntxt | 16 +++++++++++----- 4 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 Resources/screens/_timer.sbntxt diff --git a/Resources/screens/_icon_data.sbntxt b/Resources/screens/_icon_data.sbntxt index 4263654..5a91a96 100644 --- a/Resources/screens/_icon_data.sbntxt +++ b/Resources/screens/_icon_data.sbntxt @@ -1,8 +1,8 @@ {{ func icon_data(sIconName, sText) }} -{{ if (sText | string.strip | string.size ) > 0}} - - - - -{{ end }} + {{ if (sText | string.strip | string.size ) > 0}} + + + + + {{ end }} {{ end }} \ No newline at end of file diff --git a/Resources/screens/_media_player.sbntxt b/Resources/screens/_media_player.sbntxt index 0e55eef..a196baa 100644 --- a/Resources/screens/_media_player.sbntxt +++ b/Resources/screens/_media_player.sbntxt @@ -26,14 +26,15 @@ {{ if state == "playing" media_position = hass.get_attribute sPlayer "media_position" | to_float media_duration = hass.get_attribute sPlayer "media_duration" | to_float + media_duration_ts = timespan.from_seconds media_duration media_updated = hass.get_attribute sPlayer "media_position_updated_at" | date.parse media_start = media_updated | date.add_seconds (-media_position) media_end = media_start | date.add_seconds media_duration }} - - + {{ icon_data "timer" (timespan.to_string media_duration_ts "c") }} + {{ icon_data "clock" (media_end | date.to_string "%T") }} {{ else if state == "paused" icon_data "pause" " -> Pausiert <- " diff --git a/Resources/screens/_timer.sbntxt b/Resources/screens/_timer.sbntxt new file mode 100644 index 0000000..168ae36 --- /dev/null +++ b/Resources/screens/_timer.sbntxt @@ -0,0 +1,20 @@ +{{ func timer() }} + {{ + start_time = hass.get_datetime "input_datetime.googletimerstart" + end_time = hass.get_datetime "input_datetime.googletimerover" + timer_text = hass.get_state "input_text.countdown_text" + }} + + {{ if start_time.year < 2000 + ret 0 + end}} + + + + {{ icon_data "hourglass-start" (start_time | date.to_string "%T") }} + {{ icon_data "hourglass-end" (end_time | date.to_string "%T") }} + + + {{ ret 1 }} + +{{ end }} \ No newline at end of file diff --git a/Resources/screens/main.sbntxt b/Resources/screens/main.sbntxt index c12e93d..00ca714 100644 --- a/Resources/screens/main.sbntxt +++ b/Resources/screens/main.sbntxt @@ -1,6 +1,9 @@ {{ include "_media_player" include "_icon_data" + include "_timer" + + items = 0 media_players = [ "media_player.buro", @@ -31,19 +34,22 @@ - + {{ icon_data "couch" (hass.get_float_state "sensor.smart_hygrometer_0998_temperature" | math.round 2) + " °C"}} {{ icon_data "cloud-sun" (hass.get_float_state "sensor.hue_outdoor_motion_sensor_1_temperature" | math.round 2) + " °C"}} + + {{ icon_data "dumbbell" (hass.get_state "sensor.fitx_auslastung") + "%" }} + + {{ for player in media_players - media_player player - end - }} + items += media_player player + end }} - + {{ items += timer }}