Comments (13)
@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.
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.
Related Issues (20)
- Mobile App is reporting failure to setup mobile phone previously used HOT 1
- The Data Recorder saves incorrect values when Home Assistant restarts. HOT 1
- Tado Hot Water Issues HOT 2
- 2024.6.2 ping integration broken - returns unavailable state instead of disconnected HOT 10
- Waze route include doesn't work HOT 1
- 2024.6.2 installation crashes HOT 2
- Radio eventually stops responding via HA commands until integration is reloaded. HOT 1
- Tesla Powerwall HOT 2
- Unifi G4 DoorBell Pro POE - intergration fails with custom image HOT 2
- Detected blocking call to open inside the event loop by integration 'openai_conversation' HOT 2
- Timeout error with Schlage integration HOT 1
- Integration Modbus - Error with Core Version > 2024.3.3 HOT 9
- Please keep Harmony switch entity - it's the only one that works properly with Siri voice HOT 5
- AlarmDecoder doesn't work with 2024.6.1 or 2024.6.2 HOT 8
- Why doesn't CORE undertake action on all reported Tuya issues ? HOT 1
- Sonoff Zigbee Temperature Sensor not updating Humidity/Temperature HOT 4
- Missing Tibber Meter entity HOT 2
- Linksys Smart Wi-Fi does not work. HOT 1
- Unifi Protect Error on startup HOT 6
- unknown UTC error 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.