Skip to content

Commit

Permalink
Merge pull request #59 closes #58
Browse files Browse the repository at this point in the history
Add name as config item
  • Loading branch information
joBr99 authored Mar 24, 2022
2 parents 4151aba + 8813331 commit 48ed2da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ key | optional | type | default | description
`class` | False | string | | The name of the Class.
`config` | False | complex | | Config/Mapping between Homeassistant and your NsPanel

### Override Icons
### Override Icons or Names

To override Icons of entities you can configure an icon name in your configuration, please see the following example.
To override Icons or Names of entities you can configure an icon and/or name in your configuration, please see the following example.
Only the icons listed in the [Icon Table](HMI#icons-ids) are useable.

```yaml
Expand All @@ -322,6 +322,7 @@ Only the icons listed in the [Icon Table](HMI#icons-ids) are useable.
- light.schreibtischlampe
- switch.deckenbeleuchtung_hinten:
icon: lightbulb
name: Lampe
- delete
- delete
- type: cardMedia
Expand Down
6 changes: 4 additions & 2 deletions apps/nspanel-lovelace-ui/nspanel-lovelace-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,10 @@ def generate_page(self, page_number):

def generate_entities_item(self, item):
icon = None
name = None
if type(item) is dict:
icon = next(iter(item.items()))[1]['icon']
icon = next(iter(item.items()))[1].get('icon')
name = next(iter(item.items()))[1].get('name')
item = next(iter(item.items()))[0]

# type of the item is the string before the "." in the item name
Expand All @@ -449,7 +451,7 @@ def generate_entities_item(self, item):
return f",text,{item},{get_icon_id('alert-circle-outline')},17299,Not found check, apps.yaml"

entity = self.api.get_entity(item)
name = entity.attributes.friendly_name
name = name if name is not None else entity.attributes.friendly_name

if item_type == "cover":
icon_id = get_icon_id_ha("cover", state=entity.state, overwrite=icon)
Expand Down

0 comments on commit 48ed2da

Please sign in to comment.