question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Access objects in entities

See original GitHub issue

Hello!

Great board, great job!

How can i access an entities objects, like for the weather?

Im trying &weather.smhi.attributes.forecast[1].temperature like i can do in homeassistant, but it only prints [object Object],[object Object]…etc.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
pointlevelcommented, Dec 7, 2019

Solved it like this:

list: [1,2,3,4,5].map(function (id) {
                        return {
                           date: function () {
                              var weekday = new Array(7);
                              weekday[0] = "Sön";
                              weekday[1] = "Mån";
                              weekday[2] = "Tis";
                              weekday[3] = "Ons";
                              weekday[4] = "Tor";
                              weekday[5] = "Fre";
                              weekday[6] = "Lör";
                              var d = new Date(Date.now() + id * 24 * 60 * 60 * 1000);
                              return weekday[d.getDay()];
                           },
                           icon: function() {
                              var sensor = this.states['weather.smhi_home'];
                              return sensor.attributes.forecast[id].condition;
                           },
                           primary: function() {
                              var sensor = this.states['weather.smhi_home'];
                              var forecast = sensor.attributes.forecast[id].templow + " - ";
                              forecast += sensor.attributes.forecast[id].temperature + "°C";
                              
                              return forecast;
                           },
                           //secondary: ''
                        }                   
                     })

Thanks for pointing me in the right direction.

0reactions
pointlevelcommented, Dec 6, 2019

Sorry, but i dont get the idea! I have to pull the state from an array of objects inside an attribute as i explained earlier. This example shows the state from an sensor.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity object (Access) - Microsoft Learn
Use the Item property of the Entities collection to return an Entity object. Use the Operations property to return the operations defined ...
Read more >
What Is an Entity Object? - Oracle Help Center
Another way of looking at it is that an entity object stores the business logic and column information for a database table (or...
Read more >
Accessing an object using another object in Entity Framework
Just a straight forward join: var result = (from c in db.Cancellations join s in db.Service on c.CustomerID equals s.ID join b in...
Read more >
Difference between Entity and Object - GeeksforGeeks
1. Entity is a real time object that can be distinguished from other objects. Object is an entity that has all the attributes...
Read more >
Retrieving JPA Entity Objects - ObjectDB
If a requested entity object is not found in the persistence context a new object is constructed and filled with data that is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found