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

support state value templates #743

Open
thatkookooguy opened this issue May 4, 2024 · 1 comment
Open

support state value templates #743

thatkookooguy opened this issue May 4, 2024 · 1 comment

Comments

@thatkookooguy
Copy link

thatkookooguy commented May 4, 2024

Is your feature request related to a problem? Please describe.
In the new roborock home assistant integration, you have a separate sensor.roborock_s8_pro_ultra_status to report a more specific status (like cleaning the mop or charging). I want to merge the normal status with this one, or show it somewhere in the card
Describe the solution you'd like
an option to set a different entity for the status report, or just use a template

Describe alternatives you've considered
adding it under the normal state with card mod
this is what I currently do to show both (but it doesn't work on the dashboard view. only the preview):

type: custom:vacuum-card
entity: vacuum.roborock_s8_pro_ultra
card_mod:
  style: |
    .metadata .status {
      flex-wrap: wrap;
    }
    
    .metadata .status:after {
      content: '{{ states('sensor.roborock_s8_pro_ultra_status') | replace('_', ' ') }}';
      display: block;
      text-transform: capitalize;
      color: var(--vc-secondary-text-color);
      width: 100%;
      opacity: 0.6;
    }

    .metadata .status .status-text {
      margin-left: 28px;
    }
stats:
  default:
    - entity_id: sensor.roborock_s8_pro_ultra_filter_time_left
      unit: hours
      subtitle: Filter
      value_template: '{{ (value | float(0) / 3600) | round(1) }}'
    - unit: hours
      entity_id: sensor.roborock_s8_pro_ultra_side_brush_time_left
      subtitle: Side brush
      value_template: '{{ (value | float(0) / 3600) | round(1) }}'
    - entity_id: sensor.roborock_s8_pro_ultra_main_brush_time_left
      value_template: '{{ (value | float(0) / 3600) | round(1) }}'
      unit: hours
      subtitle: Main brush
    - entity_id: sensor.roborock_s8_pro_ultra_sensor_time_left
      value_template: '{{ (value | float(0) / 3600) | round(1) }}'
      unit: hours
      subtitle: Sensors
  cleaning:
    - entity_id: sensor.roborock_s8_pro_ultra_cleaning_time
      value_template: '{{ (value | float(0) / 3600) | round(1) }}'
      unit: minutes
      subtitle: Cleaning time
    - entity_id: sensor.roborock_s8_pro_ultra_main_brush_time_left
      value_template: '{{ (value | float(0) / 3600) | round(1) }}'
      subtitle: Main brush
      unit: hours
shortcuts:
  - name: Clean living room
    service: script.clean_living_room
    icon: mdi:sofa
  - name: Clean bedroom
    service: script.clean_bedroom
    icon: mdi:bed-empty
  - name: Clean kitchen
    service: script.clean_kitchen
    icon: mdi:silverware-fork-knife

image

@thatkookooguy
Copy link
Author

thatkookooguy commented May 4, 2024

this worked to make the addition to the card persistent:

type: custom:mod-card
card:
  type: custom:vacuum-card
  entity: vacuum.roborock_s8_pro_ultra
  show_name: true
  show_status: true
  show_toolbar: true
  compact_view: false
  stats:
    default:
      - entity_id: sensor.roborock_s8_pro_ultra_filter_time_left
        unit: hours
        subtitle: Filter
        value_template: '{{ (value | float(0) / 3600) | round(1) }}'
      - unit: hours
        entity_id: sensor.roborock_s8_pro_ultra_side_brush_time_left
        subtitle: Side brush
        value_template: '{{ (value | float(0) / 3600) | round(1) }}'
      - entity_id: sensor.roborock_s8_pro_ultra_main_brush_time_left
        value_template: '{{ (value | float(0) / 3600) | round(1) }}'
        unit: hours
        subtitle: Main brush
      - entity_id: sensor.roborock_s8_pro_ultra_sensor_time_left
        value_template: '{{ (value | float(0) / 3600) | round(1) }}'
        unit: hours
        subtitle: Sensors
    cleaning:
      - entity_id: sensor.roborock_s8_pro_ultra_cleaning_time
        value_template: '{{ (value | float(0) / 3600) | round(1) }}'
        unit: minutes
        subtitle: Cleaning time
      - entity_id: sensor.roborock_s8_pro_ultra_main_brush_time_left
        value_template: '{{ (value | float(0) / 3600) | round(1) }}'
        subtitle: Main brush
        unit: hours
  shortcuts:
    - name: Clean living room
      service: script.clean_living_room
      icon: mdi:sofa
    - name: Clean bedroom
      service: script.clean_bedroom
      icon: mdi:bed-empty
    - name: Clean kitchen
      service: script.clean_kitchen
      icon: mdi:silverware-fork-knife
card_mod:
  style:
    vacuum-card $: |
      .metadata .status {
        flex-wrap: wrap;
      }

      .metadata .status::after {
        content: '{{ states('sensor.roborock_s8_pro_ultra_status') | replace('_', ' ') }}';
        display: block;
        text-transform: capitalize;
        color: var(--vc-secondary-text-color);
        width: 100%;
        opacity: 0.6;
      }

      .metadata .status .status-text {
        margin-left: 28px;
      }

        .metadata .status .status-text {
          margin-left: 28px;
        }

It's the same code just inside a custom:mod-card and using $ to penetrate the shadow dom isolation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant