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

Data attribute is a string and not an object #12

Open
jumping2000 opened this issue Aug 3, 2020 · 0 comments
Open

Data attribute is a string and not an object #12

jumping2000 opened this issue Aug 3, 2020 · 0 comments

Comments

@jumping2000
Copy link

jumping2000 commented Aug 3, 2020

Version of the custom_component

Emby Latest Media 0.3.4

Configuration

- platform: emby_upcoming_media
  api_key: !secret apikey
  user_id: !secret userid
  host: !secret host
  port: !secret port
  ssl: false
  max: 5
  use_backdrop: false
  include:
    - Film
    - Serie TV

Describe the bug

The component is working, but the "data" attribute is a string and not an object so it's not usable with jinjia in HA.
Please could you make the "data" attribute an object?
thanks

{{ states.sensor.emby_latest_film.attributes.data is string }} gives true

{{ state_attr('sensor.emby_latest_film', 'data') is string }} gives true

the above code is not working because the data attribute is a string:

          
          {% set data = state_attr('sensor.emby_latest_film', 'data') %} 
          {{ data[1].title }}
          {%- if data[1].release is none -%} ({{ data[1].aired.split('-')[0] }})
          {% else %} ({{ data[1].release }}) {% endif %}

I see that people using the component Plex Recently Added Component (https://github.com/custom-components/sensor.plex_recently_added) that gives a similar "data" attribute can use Jinjia templates with HA.

THE SOLUTION SEEMS TO BE:
replace attributes["data"] = json.dumps(card_json)
with attributes['data'] = card_json
in sensor.py

Debug log


Add your logs here.

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

No branches or pull requests

1 participant