Merge pull request #6 from AalianKhan/AalianKhan-patch-1

Added fix for weather entity error
This commit is contained in:
Aalian Khan
2023-04-04 02:34:17 -04:00
committed by GitHub
2 changed files with 91 additions and 52 deletions

View File

@@ -92,11 +92,11 @@ If you created a entity in your `configuratation.yaml` you may need to enter a `
You can set strategy options to further customize the dashboard. It has the following availible options You can set strategy options to further customize the dashboard. It has the following availible options
| Name | Type | Default | Description | | Name | Type | Default | Description |
|:---------------------|:-----------------------|:------------------------|:-----------------------------------------------------------------------------------------| |:---------------------|:-----------------------|:--------------------------------------------------------|:-----------------------------------------------------------------------------------------|
| `areas` | list | Optional | One or more areas in a list, see [areas object](#area-object) | | `areas` | list | Optional | One or more areas in a list, see [areas object](#area-object) |
| `entity_config` | list of cards | Optional | Card defination for an entity, see [entity config](#entity-config) | | `entity_config` | list of cards | Optional | Card defination for an entity, see [entity config](#entity-config) |
| `views` | object | All views enabled | Setting which pre-built views to show, see available [Pre-built views](#pre-built-views) | | `views` | object | All views enabled | Setting which pre-built views to show, see available [Pre-built views](#pre-built-views) |
| `chips` | object | All count chips enabled | Setting which pre-built chips to show, see available [chips](#pre-built-chips) | | `chips` | object | All count chips enabled with auto selected weather card | See [chips](#pre-built-chips) |
| `quick_access_cards` | list of cards | Optional | List of cards to show between welcome card and rooms cards | | `quick_access_cards` | list of cards | Optional | List of cards to show between welcome card and rooms cards |
| `extra_cards` | list of cards | Optional | List of cards to show below room cards | | `extra_cards` | list of cards | Optional | List of cards to show below room cards |
| `extra_chips` | list of mushroom chips | Optional | List of chips to show on home view | | `extra_chips` | list of mushroom chips | Optional | List of chips to show on home view |
@@ -197,12 +197,14 @@ views:
Mushroom strategy has chips that count the number of devices active for a specific domain. Only the devices that are in an area and is also defined in `areas` are counted. By default, all chips are enabled Mushroom strategy has chips that count the number of devices active for a specific domain. Only the devices that are in an area and is also defined in `areas` are counted. By default, all chips are enabled
| Availible chips | type | Description | | Availible chips | type | Description |
|:----------------|:--------|:--------------------------------------------------------------------------------------------------------------| |:----------------|:--------|:------------------------------------------------------------------------------------------------------------------|
| `light_count` | boolean | chip to display the number of lights on, tapping turns off all lights, holding navigates to lights view | | `light_count` | Boolean | Chip to display the number of lights on, tapping turns off all lights, holding navigates to lights view |
| `fan_count` | boolean | chip to display the number of fans on, tapping turns off all fans, holding navigates to fans view | | `fan_count` | Boolean | Chip to display the number of fans on, tapping turns off all fans, holding navigates to fans view |
| `cover_count` | boolean | chip to display the number of covers not closed, tapping navigates to covers view | | `cover_count` | Boolean | Chip to display the number of covers not closed, tapping navigates to covers view |
| `switch_count` | boolean | chip to display the number of switches on, tapping turns off all switches, holding navigates to switches view | | `switch_count` | Boolean | Chip to display the number of switches on, tapping turns off all switches, holding navigates to switches view |
| `climate_count` | boolean | chip to display the number of climate not off, tapping naviagetes to climates view | | `climate_count` | Boolean | Chip to display the number of climate not off, tapping naviagetes to climates view |
| `weather_entity` | Entity ID | Entity ID for the weather chip to use, accepts `weather.` only |
| `extra_chips` | List | List of extra chips to display, see [Mushroom Chips][mushroom-chips] |
#### Example #### Example
@@ -210,6 +212,21 @@ Mushroom strategy has chips that count the number of devices active for a specif
chips: chips:
climate_count: false climate_count: false
cover_count: false cover_count: false
weather_entity: weather.forecast_home
extra_chips:
- type: conditional
conditions:
- entity: lock.front_door
state: unlocked
chip:
type: entity
entity: lock.front_door
icon_color: red
content_info: none
icon: ''
use_entity_picture: false
tap_action:
action: toggle
``` ```
## Full Example ## Full Example
@@ -225,8 +242,34 @@ strategy:
cameras: true cameras: true
thermostats: false thermostats: false
chips: chips:
weather_entity: weather.forecast_home
climate_count: false climate_count: false
cover_count: false cover_count: false
extra_chips:
- type: conditional
conditions:
- entity: lock.front_door
state: unlocked
chip:
type: entity
entity: lock.front_door
icon_color: red
content_info: none
icon: ''
use_entity_picture: false
tap_action:
action: toggle
- type: conditional
conditions:
- entity: cover.garage_door
state_not: closed
chip:
type: entity
entity: cover.garage_door
icon_color: red
content_info: none
tap_action:
action: toggle
areas: areas:
- name: Family Room - name: Family Room
icon: mdi:television icon: mdi:television
@@ -275,31 +318,6 @@ strategy:
- type: custom:mushroom-entity-card - type: custom:mushroom-entity-card
entity: sensor.front_door_lock_battery entity: sensor.front_door_lock_battery
name: Battery name: Battery
extra_chips:
- type: conditional
conditions:
- entity: lock.front_door
state: unlocked
chip:
type: entity
entity: lock.front_door
icon_color: red
content_info: none
icon: ''
use_entity_picture: false
tap_action:
action: toggle
- type: conditional
conditions:
- entity: cover.garage_door
state_not: closed
chip:
type: entity
entity: cover.garage_door
icon_color: red
content_info: none
tap_action:
action: toggle
extra_cards: extra_cards:
- type: custom:xiaomi-vacuum-map-card - type: custom:xiaomi-vacuum-map-card
map_source: map_source:
@@ -339,6 +357,7 @@ strategy:
[home-assitant-theme-docs]: https://www.home-assistant.io/integrations/frontend/#defining-themes [home-assitant-theme-docs]: https://www.home-assistant.io/integrations/frontend/#defining-themes
[hacs]: https://hacs.xyz [hacs]: https://hacs.xyz
[mushroom]: https://github.com/piitaya/lovelace-mushroom [mushroom]: https://github.com/piitaya/lovelace-mushroom
[mushroom-chips]: https://github.com/piitaya/lovelace-mushroom/blob/main/docs/cards/chips.md
[mini-graph]: https://github.com/kalkih/mini-graph-card [mini-graph]: https://github.com/kalkih/mini-graph-card
[webrtc]: https://github.com/AlexxIT/WebRTC [webrtc]: https://github.com/AlexxIT/WebRTC
[balloobBattery]: https://gist.github.com/balloob/4a70c83287ddba4e9085cb578ffb161f [balloobBattery]: https://gist.github.com/balloob/4a70c83287ddba4e9085cb578ffb161f

View File

@@ -347,15 +347,35 @@ class MushroomStrategy {
const chips = [] const chips = []
// weather // weather
if (strategyOptions.chips != null && strategyOptions.chips.weather_entity != null)
{
chips.push chips.push
( (
{ {
type: "weather", type: "weather",
entity: "weather.forecast_home", entity: strategyOptions.chips.weather_entity,
show_temperature: true, show_temperature: true,
show_conditions: true show_conditions: true
}, }
) )
} else
{
const weatherEntity = entities.find(entity => entity.entity_id.startsWith("weather.") && entity.disabled_by == null)
if (weatherEntity != null)
{
chips.push
(
{
type: "weather",
entity: weatherEntity.entity_id,
show_temperature: true,
show_conditions: true
}
)
}
}
// Light count // Light count
const lightCountTemplate = "{% set lights = [" + createListOfFilteredStates(entities, devices, definedAreas, "light.") + "] %} {{ lights | selectattr('state','eq','on') | list | count }}"; const lightCountTemplate = "{% set lights = [" + createListOfFilteredStates(entities, devices, definedAreas, "light.") + "] %} {{ lights | selectattr('state','eq','on') | list | count }}";
@@ -489,10 +509,10 @@ class MushroomStrategy {
} }
// Extra cards // Extra cards
if (strategyOptions.extra_chips != null) { if (strategyOptions.chips != null && strategyOptions.chips.extra_chips != null) {
chips.push chips.push
( (
...strategyOptions.extra_chips ...strategyOptions.chips.extra_chips
) )
} }