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

Strong integration with magic areas. #32

Open
PhillipRt opened this issue Jul 7, 2023 · 4 comments
Open

Strong integration with magic areas. #32

PhillipRt opened this issue Jul 7, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@PhillipRt
Copy link

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

@PhillipRt PhillipRt added the enhancement New feature or request label Jul 7, 2023
@DigiLive
Copy link
Collaborator

DigiLive commented Jul 8, 2023

Relates to #16

@DigiLive
Copy link
Collaborator

DigiLive commented Jul 8, 2023

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

@DigiLive DigiLive added the Needs Feedback Something needs clarification or a response is expected label Jul 8, 2023
@floco
Copy link

floco commented Sep 3, 2023

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 DigiLive removed the Needs Feedback Something needs clarification or a response is expected label Sep 19, 2023
@AalianKhan AalianKhan self-assigned this Sep 26, 2023
@DigiLive
Copy link
Collaborator

Taken over by #75.

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

No branches or pull requests

4 participants