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

What to do if a sensor has an attribute in the form of an array? #17

Open
ericvb opened this issue May 28, 2020 · 5 comments
Open

What to do if a sensor has an attribute in the form of an array? #17

ericvb opened this issue May 28, 2020 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@ericvb
Copy link

ericvb commented May 28, 2020

What to do if a sensor has an attribute in the form of an array like the attribute next_passages?

sensor.kerk
 	
attribution: Data provided by data.delijn.be
stopname: Kerk
line_number_public: 2
line_transport_type: BUS
final_destination: Antwerpen
due_at_schedule: 2020-05-28T17:42:00+00:00
due_at_realtime: 2020-05-28T17:42:00+00:00
next_passages: 
- passage: 0
  line_number: 800
  direction: HEEN
  final_destination: Antwerpen
  due_at_schedule: '2020-05-28T17:42:00+00:00'
  due_at_realtime: '2020-05-28T17:42:00+00:00'
  due_in_min: 16
  is_realtime: false
  line_number_public: '2'
  line_desc: Diplomatenwijk
  line_transport_type: BUS
  line_number_colourFront: WI
  line_number_colourFrontHex: FFFFFF
  line_number_colourBack: GR
  line_number_colourBackHex: '229922'
  line_number_colourFrontBorder: ZW
  line_number_colourFrontBorderHex: '000000'
  line_number_colourBackBorder: GR
  line_number_colourBackBorderHex: '229922'
  stopname: 'Kerk'
- passage: 1
  line_number: 800
  direction: HEEN
  final_destination: Antwerpen
  due_at_schedule: '2020-05-28T17:42:00+00:00'
  due_at_realtime: '2020-05-28T17:42:00+00:00'
  due_in_min: 16
  is_realtime: false
  line_number_public: '2'
  line_desc: Diplomatenwijk
  line_transport_type: BUS
  line_number_colourFront: WI
  line_number_colourFrontHex: FFFFFF
  line_number_colourBack: GR
  line_number_colourBackHex: '229922'
  line_number_colourFrontBorder: ZW
  line_number_colourFrontBorderHex: '000000'
  line_number_colourBackBorder: GR
  line_number_colourBackBorderHex: '229922'
  stopname: 'Kerk'

friendly_name: Kerk
icon: mdi:bus
device_class: timestamp

The attribute next_passages can have multiple passages.
In the example above there are two passages, but we can have 3 or 4 or … passages

@bcutter
Copy link

bcutter commented Jun 25, 2021

I´m curious to see this too. Currently my attribute has only one line (I use it mainly for showing available updates and currently all sensors attributes unfortunately only have one available update...). Will test how entity-attributes-card behaves as soon as one attribute contains more elements (lines) and probably come back here...

@bcutter
Copy link

bcutter commented Jun 28, 2021

...aaaand I hit it too:

image

image

How to handle (show) that? Currently the card only shows an "object" text which is not useful at all... I want ALL of that attributes content to show up instead.

Any suggestions / workarounds?

@iantrich iantrich added the help wanted Extra attention is needed label Aug 12, 2021
@ChristophCaina
Copy link

OK, I am also running into this issue...
The Attributes of one Sensore are an array...

engine:
  engine_type: iV
  power_in_kw: 132
  battery_capacity_kwh: 62

So, I can only select "engine" in the attributes card, which will show the [object Object] pattern:
grafik

@bcutter
Copy link

bcutter commented Sep 16, 2022

Have a look at the flex-table-card. I replaced most of my entity-attributes-card already with it.

@ghost
Copy link

ghost commented Mar 15, 2023

Have a look at the flex-table-card. I replaced most of my entity-attributes-card already with it.

The card looks awesome, but for the life of me, I do not understand the docs.

I am trying to use it with an array. Any chance you can give me a pointer? The array in question is from Watchman (HACS) sensor.watchman_missing_entities which has an array under entities. Pic below
Screenshot 2023-03-15 at 09 47 07

I've tries all sorts of variations on:

  - type: custom:flex-table-card
    title: Missing entities
    entities:
      include: sensor.watchman_missing_entities
    columns:
      - name: Entity
        data: entities.id
      - name: State
        data: entities.state

...with and without entities, with and without the utterly confusing receivedTS and sendTS from the docs.

Any pointer would be appreciated. I know I can raise a ticker there, but thought you might be able to help with a dumb question like mine.


edit: typically, after posting for help, one finds the right thread to answer it!
this thread (using weather.openweathermap) helped me crack it.

The answer, for me, is:

  - type: custom:flex-table-card
    title: Missing entities
    entities:
      include: sensor.watchman_missing_entities
    columns:
      - name: Entity
        data: entities
        modify: x.id
      - name: State
        data: entities
        modify: x.state
      - name: Occurances
        data: entities
        modify: x.occurrences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants