Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uptime unit bug. #894

Open
Ainndy opened this issue Jan 3, 2025 · 19 comments
Open

Uptime unit bug. #894

Ainndy opened this issue Jan 3, 2025 · 19 comments
Labels
bug Something isn't working

Comments

@Ainndy
Copy link

Ainndy commented Jan 3, 2025

image
image

@Ainndy Ainndy added the bug Something isn't working label Jan 3, 2025
@ngocjohn
Copy link

ngocjohn commented Jan 3, 2025

This is not a bug, use helpers to format datetime..
https://github.com/custom-cards/button-card?tab=readme-ov-file#javascript-templates
CleanShot 2025-01-03 at 15 30 08@2x

@Ainndy
Copy link
Author

Ainndy commented Jan 3, 2025

This is not a bug, use helpers to format datetime..

https://github.com/custom-cards/button-card?tab=readme-ov-file#javascript-templates

CleanShot 2025-01-03 at 15 30 08@2x

Which one should I choose for this format [* d * h]. thanks

@ngocjohn
Copy link

ngocjohn commented Jan 3, 2025

Can you show me the state via dev tools template?
CleanShot 2025-01-03 at 15 40 43

@Ainndy
Copy link
Author

Ainndy commented Jan 3, 2025

Can you show me the state via dev tools template?

CleanShot 2025-01-03 at 15 40 43

image

image

@ngocjohn
Copy link

ngocjohn commented Jan 3, 2025

@Ainndy use correct template ..

{{ states.sensor.uptime.state }}

change with your sensor entity..

@Ainndy
Copy link
Author

Ainndy commented Jan 3, 2025

@Ainndy use correct template ..


{{ states.sensor.uptime.state }}

change with your sensor entity..

My entity is the sensor.water_server_uptime_sensor ..

@ngocjohn
Copy link

ngocjohn commented Jan 3, 2025

I know, but you have to know what its state shows.. use this in template and send screen..

{{ states.sensor.water_server_uptime_sensor.state }}

@Ainndy
Copy link
Author

Ainndy commented Jan 3, 2025

I know, but you have to know what its state shows.. use this in template and send screen..


{{ states.sensor.water_server_uptime_sensor.state }}

1.5769

image

@ngocjohn
Copy link

ngocjohn commented Jan 3, 2025

Ok, so it's not a date time object... how do you have the button-card set?

@Ainndy
Copy link
Author

Ainndy commented Jan 3, 2025

好的,所以它不是一个日期时间对象......你是如何设置按钮卡的?

Ok, so it's not a date time object... how do you have the button-card set?

The entity is esphome uptime, homeassistant supports displaying the day time unit, but the button card does not support displaying it.
https://esphome.io/components/sensor/uptime.html

type: custom:button-card
entity: sensor.water_server_uptime_sensor
color: lightgreen
show_icon: false
show_name: true
show_state: true
styles:
card:
- background-color: lightgreen
- border-radius: 18px
- box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2)
- width: 80px
- height: 30px
- padding: 15px
- border: none
name:
- font-size: 11px
- color: gray
- margin-bottom: "-1px"
state:
- font-size: 12px
- color: black
- margin-bottom: "-1px"
style:
z-index: 3
top: 95%
left: 87.5%
transform: translate(-50%, -50%)

@ngocjohn
Copy link

ngocjohn commented Jan 3, 2025

use this to change the state to format d:h, its just calculated to total whole day and hours..

state_display: >
  [[[
    let days = entity.state;
    const wholeDays = Math.floor(days); // Extract the full days
    const hours = Math.round((days - wholeDays) * 24);
    return `${wholeDays}d:${hours}h`;
  ]]]

@Ainndy
Copy link
Author

Ainndy commented Jan 3, 2025

use this to change the state to format d:h, its just calculated to total whole day and hours..


state_display: >

  [[[

    let days = entity.state;

    const wholeDays = Math.floor(days); // Extract the full days

    const hours = Math.round((days - wholeDays) * 24);

    return `${wholeDays}d:${hours}h`;

  ]]]

OK, thank you very much

@Ainndy
Copy link
Author

Ainndy commented Jan 10, 2025

use this to change the state to format d:h, its just calculated to total whole day and hours..

state_display: >
  [[[
    let days = entity.state;
    const wholeDays = Math.floor(days); // Extract the full days
    const hours = Math.round((days - wholeDays) * 24);
    return `${wholeDays}d:${hours}h`;
  ]]]

Hello, how to make a single button and three buttons in a grid card have the same height?
image

type: horizontal-stack
cards:
  - square: true
    type: grid
    cards:
      - type: custom:button-card
        name: Living Room
        icon: mdi:sofa
        entity: sensor.wi_fizhi_neng_yao_kong_temperature
        show_state: true
        custom_fields:
          btn:
            card:
              type: vertical-stack
              cards:
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  entity: switch.water_server_ring_switch
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  entity: switch.water_server_ring_switch
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  entity: switch.water_server_ring_switch
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
        styles:
          grid:
            - grid-template-areas: "\"n btn\" \"s btn\" \"i btn\""
            - grid-template-columns: 1fr min-content
            - grid-template-rows: min-content min-content 1fr;
          card:
            - padding: 22px
          custom_fields:
            btn:
              - justify-content: end
              - align-self: start
          name:
            - justify-self: start
            - align-self: start
            - fonr-size: 18px
            - font-weight: 500
            - color: black
          icon:
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
            - opacity: "0.6"
          state:
            - min-height: 80px
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
          img_cell:
            - justify-content: start
            - position: absolute
            - width: 130px
            - height: 130px
            - left: 0
            - bottom: 0
            - margin: 0 0 -30px -30px
            - background: red
            - border-radius: 500px
      - type: custom:button-card
        name: Living Room
        icon: mdi:sofa
        entity: sensor.wi_fizhi_neng_yao_kong_temperature
        show_state: true
        custom_fields:
          btn:
            card:
              type: vertical-stack
              cards:
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
        styles:
          grid:
            - grid-template-areas: "\"n btn\" \"s btn\" \"i btn\""
            - grid-template-columns: 1fr min-content
            - grid-template-rows: min-content min-content 1fr;
          card:
            - padding: 22px
          custom_fields:
            btn:
              - justify-content: end
              - align-self: start
          name:
            - justify-self: start
            - align-self: start
            - fonr-size: 18px
            - font-weight: 500
            - color: black
          icon:
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
            - opacity: "0.6"
          state:
            - min-height: 80px
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
          img_cell:
            - justify-content: start
            - position: absolute
            - width: 130px
            - height: 130px
            - left: 0
            - bottom: 0
            - margin: 0 0 -30px -30px
            - background: red
            - border-radius: 500px
    columns: 2

@ngocjohn
Copy link

Remove the horizontal-stack, put buttons to grid?

square: false
type: grid
cards:
  - type: custom:button-card
    entity: sun.sun
  - type: custom:button-card
    entity: sun.sun
columns: 2

@Ainndy
Copy link
Author

Ainndy commented Jan 10, 2025

sun.sun

image

square: false
type: grid
cards:
  - square: true
    type: grid
    cards:
      - type: custom:button-card
        name: Living Room
        icon: mdi:sofa
        entity: sun.sun
        show_state: true
        custom_fields:
          btn:
            card:
              type: vertical-stack
              cards:
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  entity: sun.sun
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  entity: sun.sun
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  entity: sun.sun
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
        styles:
          grid:
            - grid-template-areas: "\"n btn\" \"s btn\" \"i btn\""
            - grid-template-columns: 1fr min-content
            - grid-template-rows: min-content min-content 1fr;
          card:
            - padding: 22px
          custom_fields:
            btn:
              - justify-content: end
              - align-self: start
          name:
            - justify-self: start
            - align-self: start
            - fonr-size: 18px
            - font-weight: 500
            - color: black
          icon:
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
            - opacity: "0.6"
          state:
            - min-height: 80px
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
          img_cell:
            - justify-content: start
            - position: absolute
            - width: 130px
            - height: 130px
            - left: 0
            - bottom: 0
            - margin: 0 0 -30px -30px
            - background: red
            - border-radius: 500px
      - type: custom:button-card
        name: Living Room
        icon: mdi:sofa
        entity: sun.sun
        show_state: true
        custom_fields:
          btn:
            card:
              type: vertical-stack
              cards:
                - type: custom:button-card
                  tap_action:
                    action: toggle
                  icon: mdi:lamp
                  show_name: false
                  show_state: false
                  styles:
                    card:
                      - width: 36px
                      - height: 36px
                      - border-radius: 50%
                      - background-color: red
                      - display: flex
                      - justify-content: center
                      - align-items: center
                    icon:
                      - width: 18px
                      - height: 18px
        styles:
          grid:
            - grid-template-areas: "\"n btn\" \"s btn\" \"i btn\""
            - grid-template-columns: 1fr min-content
            - grid-template-rows: min-content min-content 1fr;
          card:
            - padding: 22px
          custom_fields:
            btn:
              - justify-content: end
              - align-self: start
          name:
            - justify-self: start
            - align-self: start
            - fonr-size: 18px
            - font-weight: 500
            - color: black
          icon:
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
            - opacity: "0.6"
          state:
            - min-height: 80px
            - justify-self: start
            - align-self: start
            - fonr-size: 14px
          img_cell:
            - justify-content: start
            - position: absolute
            - width: 130px
            - height: 130px
            - left: 0
            - bottom: 0
            - margin: 0 0 -30px -30px
            - background: red
            - border-radius: 500px
columns: 2

@ngocjohn
Copy link

square: false
type: grid
cards:

  • square: true
    type: grid
    cards:

why? Use single grid to buttons, not grid in grid.

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Jan 10, 2025

@Ainndy please dont use this issue on the uptime 'bug', for asking non related config questions about nested cards....

lets keep this tidy (we all get notified) and hop over to the community for help on config questions

o and if you do, dont post these huge configs, just the minimal section you see an issue/have question about

@Ainndy
Copy link
Author

Ainndy commented Jan 10, 2025

@Ainndy please dont use this issue on the uptime 'bug', for asking non related config questions about nested cards....

lets keep this tidy (we all get notified) and hop over to the community for help on config questions

o and if you do, dont post these huge configs, just the minimal section you see an issue/have question about

Sorry, ok...

@Ainndy
Copy link
Author

Ainndy commented Jan 10, 2025

square: false

type: grid

cards:

  • square: true
type: grid
cards:

why? Use single grid to buttons, not grid in grid.

Sending configuration codes seems to disturb others😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants