AalianKhan / mushroom-strategy

A strategy to automatically generate a dashboard using mushroom cards
MIT License
371 stars 37 forks source link

Strong integration with magic areas. #32

Open PhillipRt opened 1 year ago

PhillipRt commented 1 year ago

Magic areas already creates aggration for a lot of entities. Using this would cut down on having 15 sensors for temperature etc in one area. For example areas could provide a lot more information then just be navigation buttons Screenshot_20230708_012901_Home Assistant (only focus on rooms and Wohnzimmer)

Room icon color is based on the lights if the room. Occupancy as the blue icon. Alerts icon in red color icon, like gas leak or water leak (not currently active). Temperature across all sensors in my area (medium is calculated by magic areas),humidity and light level. It also adds the information configured in the magic areas making this bright, occupied, extended (has been occupied for a while). Click navigates to the area, click and hold turns on the light.

Here is the code:

type: custom:mushroom-template-card
primary: Wohnzimmer
secondary: >-
  🌡️{{ states('sensor.wohnzimmer_temperature')}}° 💧{{
  states('sensor.wohnzimmer_humidity')}}%
  ☀️{{states('sensor.area_illuminance_lx_wohnzimmer')|int}} lx

  {{ state_attr('binary_sensor.area_wohnzimmer', 'states') | join(', ')}}
icon: phu:rooms-living
entity: light.wohnzimmer_lights
tap_action:
  action: navigate
  navigation_path: wohnzimmer
icon_color: |-
  {% if is_state('light.wohnzimmer_lights','on')%}
    orange
  {%endif%}
badge_color: |-
  {% if is_state('binary_sensor.area_health_wohnzimmer','on')%}
    red
  {% else %}
   #68BAF7
  {%endif%}
badge_icon: |-
  {% if is_state('binary_sensor.area_health_wohnzimmer','on')%}
    mdi:information
  {% elif is_state('binary_sensor.area_wohnzimmer','on')%}
    mdi:motion-sensor
  {%endif%}
hold_action:
  action: toggle
multiline_secondary: true
fill_container: true

This is just a rough start but might interesting to build from to not make the dashboard lacking basic infromation. I do like this at a glace dashboard with no drilling down.

I am not sure if this is a road you want to go down but I am happy to contribute if this is a feature worth accepting

DigiLive commented 1 year ago

Relates to #16

DigiLive commented 1 year ago

I do like the looks of the card.

However, this strategy auto generates a dashboard without requiring any special configuration. The area card you propose does require configuration, because the sensors to read the states from, can't be known on beforehand.

Also, I think you've created your own custom sensor binary_sensor.area_wohnzimmer to show some states. This custom sensor doesn't exist for any other user.

Can you propose any solutions for above arguments?

FYI... Did you give release alpha.1 a try? That release allows you to override the strategy's default behavior of an area card, which give the requested result, e.g.:

    areas:
      kitchen:
        name: Chef's Place
        icon: mdi:countertop
        icon_color: green
        order: 1
        secondary: >-
          🌡️{{ states('sensor.hue_motion_sensor_1_temperature') }}° 💧{{
          states('sensor.rm4_pro_humidity') }}% ☀️{{
          states('sensor.hue_motion_sensor_1_illuminance') }}lx
floco commented 1 year ago

This feature is great ! Sending my config in case that can help anyone.

image

Create custom_templates folder in your configuration directory and create dashboard.jinja in that folder. Copy and paste the following in dashboard.jinja. More info

{% macro count_light(entity_filter, area, icon) %}{% set var_count = expand(area_entities(area)| select('match', entity_filter)) | selectattr('state', 'eq', 'on') | list | count %}{% if var_count != 0 %}{{ icon }}{{ var_count }}{% endif %}{% endmacro %}

{% macro count_entity(entity_filter, entity_class, area, icon) %}{% set var_count = expand(area_entities(area)| select('match', entity_filter)) | rejectattr('attributes.device_class', 'undefined') | selectattr('attributes.device_class', 'eq', entity_class) | selectattr('state', 'eq', 'on') | list | count %}{% if var_count != 0 %}{{ icon }}{{ var_count }}{% endif %}{% endmacro %}

{% macro show_info(temp,hum,lux,area) %}
❄️{{ states(temp) | int }}° 💧{{states(hum) }}% ☀️{{states(lux) }}lx 
{{ count_entity('binary_sensor.', 'window', area, '🪟') }} {{ count_entity('binary_sensor.', 'door', area, '🚪') }} {{ count_light('light.', area, '☀️') }}
{% endmacro %}

Then in the mushroom strategy.

   areas:
      garage:
        name: Garage
        icon: mdi:garage
        icon_color: green
        order: 2
        multiline_secondary: true
        secondary: >-
          {% from 'dashboard.jinja' import show_info %} {{ show_info( 
          'sensor.motion_garage_temperature', 
          'sensor.netatmo_living_room_inside_humidity',
          'sensor.motion_garage_illuminance_lux', 'Garage') }}
DigiLive commented 10 months ago

Taken over by #75.