Comments (27)
Reviewing the proposal and the quotes here, I must say that the idea of devices has grown on me a lot.
As a proposal to implement it, I would think of something like this:
- Add a new property
device
to theEntity
class. Returns an instance ofDevice
class. Defaults toNone
- Device class will have properties like manufacturer, model, firmware.
- When an entity is added to an entity platform, check if it has a device, if so, register the device with a Device Registry.
(this proposal would supersede #26)
from architecture.
I've not read through all of this, but @dgomes: For me a use case would be to have an ESP (for esphomelib 😉) exposed as a "device". Because such a microcontroller can have multiple components connected to it. For example an RGB light, a binary sensor and sensor.
The advantage would then be that each "node"/device can then be exposed as a single device and be managed like that.
Not sure if that use case applies here though, as the device concept is as far as I see quite connected to config entries.
from architecture.
Some devices eg arduinos will not have standard serial numbers available, nor will mac or ip addresses be available for all cases. I think we should have a general id for each device that is set by the developer as we have unique ids for entities.
Edit: I see now that address is separate from unique id. Nevermind then.
from architecture.
Would we be able to inherit from Devices ?
See very good candidates:
- Cars
- Personal Weather Stations
- System Monitoring (CPU, RAM, Disk)
from architecture.
Also relevant: https://iot.mozilla.org/wot/#thing-resource
from architecture.
To continue on my proposal, I realized that there are also devices that on their own do not have entities, but still should be there. For example, the Hue integration communicates with a Hub, but the hub itself is not an entity. Components should be able to also register entities.
It's up to components and devices to specify a unique ID. Unique ID will be scoped by component or platform name. So in the case of light.hue, device will be identified within hue (both component and platform).
It's important that when devices get registered, we know if they are from a config entry. We can then start generating this tree:
- config entry for Z-Wave (will enable component and point at stick)
- device: 5-in-1 sensor
- entity: temp sensor
- entity: humidity sensor
- device: Z-Wave stick
- device: 5-in-1 sensor
from architecture.
Device properties
Required:
- Component: string (hue, nest, etc)
- Unique ID: string
- Manufacturer: string
- Model: string
- Connection: string (Wifi, ethernet, Z-Wave, Zigbee, Internet)
- Config Entry ID: string
Optional:
- Address: string = (For wifi/ethernet is MAC, so we can hook it up with device tracker etc)
- Firmware version: string
- Serial NO: string
from architecture.
I wonder how we should deal with things like a TV that can be connected via Plex and via Cast and maybe via a Samsung platform?
Would that mean that the device in that case can be shared among config entries 🤔
from architecture.
Like a TV can implement multiple interfaces, Plex, Cast and Samsung. In that case, your required properties should change to:
- Unique ID: string
- Manufacturer: string
- Model: string
- Connection: list of Connection Profile
- Profile Type: string (Wifi, ethernet, Z-Wave, Zigbee, Internet)
- Profile Data: such as MAC, IP, etc
- Interfaces: list of
- Component: string (plex, case, samsung)
- Config Entry ID: string
from architecture.
Good point.
Just realized, we should be able to infer the component from the config entry.
from architecture.
So made a diagram how the different parts relate to one another.
https://docs.google.com/drawings/d/1-wR8t3L1UMRDv9LskH-rDMus4bnvgxa7OeFI_5UZAZ0/edit?usp=sharing
from architecture.
For matching up, we first check for serial match, after that we look for a match for one of the connections. Not sure if we should differentiate between wifi/ethernet because we might not know.
from architecture.
"Device can be shared between two components"
In the diagram, this use case is depicted by Device C. Device C connects to two entities belonging to Component A (Example: TV that runs two media_players).
Now I'm wondering about Device D which connects directly to Component B (example: Hue registers the Hub).
Do we have a use case for a Device that connects directly to TWO Components ?
from architecture.
The only thing I can think of is something like a server that is running a bunch of stuff.
from architecture.
@OttoWinter but would it be connected to the component or to the entity ?
I'm fine with any answer, I'm just concern with handling the consistency of all these relationships, especially those that are any-to-any.
from architecture.
It's not connected perse to config entries, entities could come from configuration yaml or discovery. Although for discovery we'll have to talk about how to define a device.
I prefer for it to be evolving around config entries because each entry represents authorization to access a service/set of devices and that makes a nice UI.
Wondering now if we should allow IP addresses as temporary identifiers, as Mac is not always accessible
from architecture.
I met a challenge may fit for Device
to resolve.
In Nest, it break up to tons of sensors, for each Nest Device, we have a binary_sensor.online
. So, in case network connection has issue, I want to use this sensor to cutoff other sensors/climate/camera's state update process to avoid flush event loop.
If we have Device
, and it has a property say online
, then everything will become very easy and clear, we should first check device's online status (no matter it maps to a separate sensor or not) before try to update any other Entity
's state.
from architecture.
The data flows from the integration to the device and entities. An integration provides the info and so doesn't need to check device
from architecture.
How do we go about a "technical" or "debug" information for a device? For example, in Zigbee world it would be tremendously helpful to have information like: Link Quality Indicator, Last Seen, Neighbors etc, which may change quite frequently, but not necessarily should trigger a state change event.
Or as another example a device representing a "network interface". it is helpful to have debugging information, like number of packets in/out, number of CRC errors, dropped packets etc.
In other words information that you don't need when everything is working fine, but is really needed during troubleshooting/error reporting
from architecture.
@Adminiuga those are sensor entities (as they currently are), which you can associate to a Device.
from architecture.
I think that such data is out of scope. Zigbee should just get their own panel like Z-Wave and make these things available. There is no need to add that to the core of HASS.
from architecture.
So I've started playing around with a device registry and there is one main thing Im trying to grasp in this design; how the actual coupling of device and entity would work. Is it enough with the device to keep a list of entity ids? Or should there be direct references to the entity objects? (Im guessing this is a big no no)
from architecture.
Why no, I would say object reference. entity_id can be changed by user.
from architecture.
I would expect it to be linked as follows:
- Each entity has a new property
device
. This property is read when an entity is passed to the Entity Platform'sadd_entities
insideasync_setup_platform
/async_setup_entry
- The device is processed in the registry, either retrieving an existing registration or creating a new one
- The entity registry will store a device id.
This means that entities that do not have a unique ID cannot be linked to a device but that makes sense. If we cannot figure out if we've seen an entity before, we can't store that data either.
from architecture.
I'd like some feedback on my initial alpha draft of device registry whether I'm in the right ball park and general comments. Also if I've misunderstood any points in the discussion above.
Thanks!
from architecture.
Initial documentation home-assistant/developers.home-assistant#81
It does need comments. Maybe we should add Paulus excellent diagram to it?
from architecture.
Yes we should! Closing this as it's considered done.
from architecture.
Related Issues (20)
- Splitting tests files in smaller files in components/modules tests HOT 1
- Feature Request HOT 1
- Add favorite position to Cover entity HOT 10
- Add feature light distribution control to LightEntity
- Add new CURRENT_HVAC constants HOT 1
- Add Home Appliance entity
- Officially allow enities to set their entity ID not based on their names HOT 2
- Custom Device Class for Binary Sensors HOT 9
- Installed homeassistant supervised on my Linux machine; can't get it to run. HOT 1
- Expand enqueue options media player HOT 2
- Extend Rest API - unique_id HOT 3
- Add "status" as an attribute to CalendarEvents HOT 5
- Add list of (upcoming) calendar events to templating HOT 1
- Creating automations on the fly HOT 1
- Optional health check HOT 2
- Open letter for improving Home Assistant's Authentication system HOT 7
- Add device_class Heater HOT 2
- Area Units HOT 3
- New Device class for Reactive Energy (varh) HOT 1
- "Lost" device 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 architecture.