Comments (15)
@bdraco
I created my first architecture discussion. Hope I did it in the right way.
In the mean time, I managed to get the one method working in pyscript (cool):
@service(supports_response="only")
def entity_integration(entity_id: str):
"""Get the integration of an entity."""
# fallback to just returning all entities for a domain
from homeassistant.helpers.entity import entity_sources
sources = entity_sources(hass)
if entity_id in sources:
return {"success":True, "result":sources[entity_id]["domain"]}
return {"success":False, "result": None}
from core.
Once the arch discussion gets a green check mark its good to go.
from core.
Hey there @OttoWinter, @jesserockz, @kbx81, @bdraco, mind taking a look at this issue as it has been labeled with an integration (esphome
) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of esphome
can trigger bot actions by commenting:
@home-assistant close
Closes the issue.@home-assistant rename Awesome new title
Renames the issue.@home-assistant reopen
Reopen the issue.@home-assistant unassign esphome
Removes the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-information
Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-information
Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
esphome documentation
esphome source
(message by IssueLinks)
from core.
This is expected. A device required connections OR identifiers, but may use both. ESPHome only uses connections as there is no internal need for identifiers
as the mac is always known in all places:
core/homeassistant/helpers/device_registry.py
Line 200 in 008b56b
from core.
@bdraco Thanks for educating 👍
Bad luck for me, I use identifiers to lookup the integration that owns the device
from core.
While I don't know your specific use case, device_attr
should be able to lookup connections
as well
core/homeassistant/helpers/template.py
Line 1365 in 008b56b
This is how devices are usually looked up
core/homeassistant/helpers/device_registry.py
Line 593 in 008b56b
from core.
Hi @bdraco
Just to explain, not a feature request.
My use case is to programmatically lookup the integration that owns an entity. I searched and googled, but this seems not supported.
Currently my approach is far from solid (I Know):
- It only works for entities that are part of a device and support the attribute 'identifiers'.
- it fails when devices own entities from multiple integrations
My template code to lookup the owning integration.
{%- set ids = device_attr(entity_id, 'identifiers') -%}
{%- set integration = 'unknown' if (not ids or ids|list|length == 0 or ids|list|first|length!=2) else ids|list|first|first -%}
This works for the majority, but fat from all entities.
The connections device attribute can indeed be queried, but the Mac doesn't help me to distill the integration:
{('mac', 'cc:8d:a2:50:90:e8')}
Bottom line two template methods are missing:
- get_integrations() -> list
- entity_integration(entity_id) -> string
Best Eric
from core.
Bottom line two template methods are missing:
- get_integrations() -> list
- entity_integration(entity_id) -> string
core/homeassistant/helpers/entity.py
Line 1448 in b7f1f80
Your template code trying to effectively reimplement a limited version entity_sources
because its not exposed to the template engine.
from core.
These can both be likely implemented with a few lines of code to wrap the existing functions as the backends already exist.
If you plan on adding these new functions to the template engine I'd start with an architecture discussion https://github.com/home-assistant/architecture/discussions
from core.
I'm not really experienced in python and github delivery processes, but I can give it a try. Thanks for the information.
from core.
This commit is a rough implementation (without tests) 3270cad
I only did light testing with it
from core.
That looks really great and so simple it would be pity when we don't add it
If I start and drive the discussion, would you be willing to deliver this when the discussing ends positive?
from core.
I'm happy to write the code if the architecture discussion results in acceptance. Its not something I would use so it needs architecture champion who is willing to advocate for it.
from core.
Great thanks for your support 👍 I will be the
My first architectural discussion, looking forward how that evolves. will initiate it tomorrow
from core.
@bdraco hi Nick
Except a few supporting votes, no response on the discussion I started. Do I have to wait longer? Or is it ok to proceed now and extend the templates with the two methods
Best Eric
from core.
Related Issues (20)
- ping is inconsistent/ambiguous for matter devices HOT 2
- missing fan_mode icons on daikin tile card HOT 6
- Opower "Unknown Error" HOT 4
- Can't access Windows share owned by user containing a space HOT 1
- Tuya - Wrong Device Category Entered By Manufacturer. DP Instructions Not Used. HOT 3
- sharing home assistant HOT 2
- Netatmo 443 error HOT 23
- Local Roborock Integration entities becomes unavailable when the internet is down HOT 3
- Unit System not retained across restarts
- Ecovacs Goat G1 - Map Error and Room error HOT 1
- Jewish Calendar entity Alot HaShachar always 14:00 HOT 4
- Holiday integration for Estonia does not show 24th of June as holiday, but it should HOT 3
- Minecraft Server not updating number of players online on java server. HOT 3
- Add support to add measurement units and other metadata HOT 6
- Sum helper from „Group“ lost unit since last update and graph is not showing correctly HOT 4
- Change unit of measurement in The Things Network sensors and TTN device tracker compatibility HOT 2
- Unable to add Matter devices over Thread HOT 6
- Can't switch from Local to Cloud HOT 3
- Unable to set manual alarm HOT 10
- Issue since one of upgrade of home assistant with Voice over ip. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.