Add source component to each entity attributes

It would be cool if all entities have a attribute like component. This would allow us to loop through them any apply different behaviors according to their component.

For example the battery level in xiaomi sensors is initially like 60. Homematic sensors seem to have a different method and initially report values like 3.

This makes it difficult to write apps in appdaemon… a homematic battery value of 2 would be perfect, in xiaomi it would be quite bade.

I don’t think that sending down the component name makes sense, because then all we are doing is making every consumer (be it appdaemon, other python modules, automation, websocket consumers) write their own logic about how much battery is good enough or not.

Balloob mentioned a preference for just creating a normalized 0-100 for sensors to report. I think that’s more granularity than they mostly have, so we probably aslo just want some constants like OK == 100, and LOW == 10 for platforms that run off of AAs to use.

I think the original wish was not that a battery value or such should be exposed, but to have a way to connect an entity to a component. If that’s still the case, I would also be for it; it would be nice to have an access to potential, platform-specific services over the API which is not currently possible as you do not know from what platform an entity came from.

Case in point, my vacuum reports the following:

            "attributes": {
                "battery_icon": "mdi:battery-charging-100",
                "battery_level": 100,
                "cleaned_area": XX,
                "cleaning_count": 161,
                "cleaning_time": XX,
                "do_not_disturb": "on",
                "fan_speed": "Turbo",
                "fan_speed_list": [
                "filter_left": 108,
                "friendly_name": "myrobot",
                "icon": "mdi:google-circles-group",
                "main_brush_left": 258,
                "side_brush_left": 158,
                "status": "Charging",
                "supported_features": 2047,
                "total_cleaned_area": 1976,
                "total_cleaning_time": 2481
            "entity_id": "vacuum.myrobot",
            "last_changed": "2017-10-10T22:20:01.909805+00:00",
            "last_updated": "2017-10-11T20:00:01.755818+00:00",
            "state": "off"

For the time being one has just to know that this vacuum supports xiaomi_remote_control_start, in which case exposing the platform (and maybe platform-specific services in the future?) could be useful.

Yes battery was just one example. It is also important for debugging.