Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useAreas not reporting moved entities correctly #105

Closed
koriwi opened this issue Nov 21, 2023 · 15 comments
Closed

useAreas not reporting moved entities correctly #105

koriwi opened this issue Nov 21, 2023 · 15 comments

Comments

@koriwi
Copy link
Collaborator

koriwi commented Nov 21, 2023

Describe the bug
I have a multi split AC in our house. but every indoor unit also reports the outside temperature sensor (basically i get 5x the same sensor). so i hid 4 of them and used one of them for the garden temperature sensor.
the sensor i use for the garden, i moved the entity into the area "garden", still shows up under the area "office" where the parent device is in. this bug only revealed itself, because my filtering for "attributes.hidden" also does not work because the field is just undefined even though i have hidden all the outside sensors. disabling them works for 4 of my 5 ACs. But i cannot disable it for my office because then i would lose the garden temp.

The entity also shows up correctly in the garden!

To Reproduce
Steps to reproduce the behavior:

  1. take a device with multiple entities.
  2. move the device into an area.
  3. move an entity of this device into another area
  4. const areas = useAreas();
  5. log the entities of your device area. the entity still shows up in the same area

Expected behavior
The moved entity should only show up in its area and not the area of its parent device

Screenshots / code examples
This screenshot should illustrate the device <-> entity difference when it comes to areas
Screenshot 2023-11-21 at 00 55 19

ctrl+f for `sensor.klimaanlage_buro_outdoor` in this json
[
    {
        "aliases": [],
        "area_id": "buro_kilian",
        "name": "Büro",
        "picture": "https://home.gosewis.ch/api/image/serve/bce805de50e6f69bef6ddde134427e88/512x512",
        "devices": [
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "a9bd2b722f91d7be7898de0f242dc768",
                    "51234ef51dc40c0e48fcb81aa5447649"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "925c0b6e42e54922a97194c207ccd287",
                "identifiers": [
                    [
                        "mqtt",
                        "zigbee2mqtt_0xeeee0302010373a4"
                    ]
                ],
                "manufacturer": "Müller Licht",
                "model": "Tint smart switch (404021)",
                "name_by_user": null,
                "name": "büro/lichtschalter",
                "serial_number": null,
                "sw_version": "2.5.3_r47",
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "1f552b73fab30f4f0627f0046ce9da43"
                ],
                "connections": [],
                "disabled_by": "config_entry",
                "entry_type": null,
                "hw_version": null,
                "id": "6ef4b6abbe12ff80cbd05aa8614fefac",
                "identifiers": [
                    [
                        "moonraker",
                        "1f552b73fab30f4f0627f0046ce9da43"
                    ]
                ],
                "manufacturer": "moonraker",
                "model": "moonraker",
                "name_by_user": null,
                "name": "Quantum Delta",
                "serial_number": null,
                "sw_version": null,
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "13d97f1ac6a5ecf8654e414a82a1ae78"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "f3bddbdd0a4c5f973e292ec45c82a89c",
                "identifiers": [
                    [
                        "mitsubishi_wf_rac",
                        "ec0baef684a4"
                    ]
                ],
                "manufacturer": "Mitsubishi (WF-RAC)",
                "model": null,
                "name_by_user": "Klimaanlage Büro",
                "name": "Airco ec0baef684a4",
                "serial_number": null,
                "sw_version": "WF-RAC, mcu: 123, wireless: 010",
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "a9bd2b722f91d7be7898de0f242dc768"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "cfbe736c4160f0819bf4fdd47e9ec761",
                "identifiers": [
                    [
                        "mqtt",
                        "zigbee2mqtt_0x0017880106a7aa73"
                    ]
                ],
                "manufacturer": "Philips",
                "model": "Hue dimmer switch (324131092621)",
                "name_by_user": null,
                "name": "büro/fernbedienung",
                "serial_number": null,
                "sw_version": "6.1.1.28573",
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "a9bd2b722f91d7be7898de0f242dc768"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "d625ff562bbb07f318a286c364e343b7",
                "identifiers": [
                    [
                        "mqtt",
                        "zigbee2mqtt_0x003c84fffef99020"
                    ]
                ],
                "manufacturer": "Moes",
                "model": "Moes BHT series Thermostat (BHT-002-GCLZB)",
                "name_by_user": null,
                "name": "büro/thermostat",
                "serial_number": null,
                "sw_version": null,
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "a9bd2b722f91d7be7898de0f242dc768"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "0321f545fac6fea5f4e88b35c798e92c",
                "identifiers": [
                    [
                        "mqtt",
                        "zigbee2mqtt_0x00158d000945e030"
                    ]
                ],
                "manufacturer": "Xiaomi",
                "model": "Aqara door & window contact sensor (MCCGQ11LM)",
                "name_by_user": null,
                "name": "büro/fenster/status",
                "serial_number": null,
                "sw_version": "3000-0001",
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "5b905a7a275eb7401b2229b3e77c5f18"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "8f78aa80ab7497976e3bf84190a12457",
                "identifiers": [
                    [
                        "mjpeg",
                        "5b905a7a275eb7401b2229b3e77c5f18"
                    ]
                ],
                "manufacturer": null,
                "model": null,
                "name_by_user": null,
                "name": "Quantum Delta",
                "serial_number": null,
                "sw_version": null,
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "4804887d8bac39ad521b929e78a409f9"
                ],
                "connections": [
                    [
                        "mac",
                        "98:f4:ab:63:e2:ec"
                    ]
                ],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "a616f975082b62635aa40780b0f1d845",
                "identifiers": [],
                "manufacturer": "Espressif",
                "model": "nodemcu-32s",
                "name_by_user": null,
                "name": "ESPHome Audio Test",
                "serial_number": null,
                "sw_version": "2023.10.6 (Nov 19 2023, 01:09:19)",
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "a9bd2b722f91d7be7898de0f242dc768"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "33759ae3d21139b51f1a5bfcef61e35e",
                "identifiers": [
                    [
                        "mqtt",
                        "zigbee2mqtt_0x7cb03eaa0a09b6be"
                    ]
                ],
                "manufacturer": "OSRAM",
                "model": "Smart+ plug (AB3257001NJ)",
                "name_by_user": null,
                "name": "büro/werkbank/steckdose/slave",
                "serial_number": null,
                "sw_version": "V1.05.09",
                "via_device_id": null
            },
            {
                "area_id": "buro_kilian",
                "configuration_url": null,
                "config_entries": [
                    "a9bd2b722f91d7be7898de0f242dc768"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": null,
                "hw_version": null,
                "id": "c30442330fea3c7c99fd94d45d5fdb4f",
                "identifiers": [
                    [
                        "mqtt",
                        "zigbee2mqtt_0xa4c1380dc128a08e"
                    ]
                ],
                "manufacturer": "TuYa",
                "model": "Human presence sensor (RTX PRO)",
                "name_by_user": null,
                "name": "büro/werkbank/anwesenheit",
                "serial_number": null,
                "sw_version": null,
                "via_device_id": null
            }
        ],
        "services": [],
        "entities": [
            {
                "entity_id": "person.kilian_gosewisch",
                "state": "home",
                "attributes": {
                    "editable": true,
                    "id": "kilian_gosewisch",
                    "latitude": 52.3142992,
                    "longitude": 13.2144835,
                    "gps_accuracy": 100,
                    "source": "device_tracker.oneplus_7t",
                    "user_id": "bc4aebd4cf0147e8bab580ce5f565d80",
                    "device_trackers": [
                        "device_tracker.oneplus_7t"
                    ],
                    "friendly_name": "Kilian Gosewisch"
                },
                "context": {
                    "id": "01HFQHV3NRP6J8TGWJE5JX9WQW",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:45.753Z",
                "last_updated": "2023-11-20T23:42:53.624Z"
            },
            {
                "entity_id": "climate.klimaanlage_buro",
                "state": "off",
                "attributes": {
                    "hvac_modes": [
                        "off",
                        "auto",
                        "cool",
                        "dry",
                        "heat",
                        "fan_only"
                    ],
                    "min_temp": 16,
                    "max_temp": 30,
                    "fan_modes": [
                        "auto",
                        "1 Lowest",
                        "2 Low",
                        "3 High",
                        "4 Highest"
                    ],
                    "swing_modes": [
                        "Up/Down Auto",
                        "Highest",
                        "Middle",
                        "Normal",
                        "Lowest",
                        "3D Auto"
                    ],
                    "current_temperature": 24.2,
                    "temperature": 24,
                    "fan_mode": "2 Low",
                    "swing_mode": "Middle",
                    "friendly_name": "Klimaanlage",
                    "supported_features": 41
                },
                "context": {
                    "id": "01HFQHV0MEHQ270QX5KDT7CFWX",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.510Z",
                "last_updated": "2023-11-20T23:42:50.510Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_accounts",
                "state": "4",
                "attributes": {
                    "unit_of_measurement": "Accounts",
                    "icon": "mdi:account-group",
                    "friendly_name": "Klimaanlage Büro Accounts"
                },
                "context": {
                    "id": "01HFQHV0Q3G8R7X5Z0Q25BYB4R",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.595Z",
                "last_updated": "2023-11-20T23:42:50.595Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_device_id",
                "state": "homeassistant-device-21555413aab",
                "attributes": {
                    "friendly_name": "Klimaanlage Büro Device ID"
                },
                "context": {
                    "id": "01HFQHV0Q3EHQM4QDJXFE3DBNE",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.595Z",
                "last_updated": "2023-11-20T23:42:50.595Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_energy_usage_cycle",
                "state": "0.0",
                "attributes": {
                    "state_class": "total_increasing",
                    "unit_of_measurement": "kWh",
                    "device_class": "energy",
                    "friendly_name": "Klimaanlage Büro energy usage cycle"
                },
                "context": {
                    "id": "01HFQHV0Q3D13P0KXT394KJ4E7",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.595Z",
                "last_updated": "2023-11-20T23:42:50.595Z"
            },
            {
                "entity_id": "select.klimaanlage_buro_horizontal_swing_direction",
                "state": "Center-Center",
                "attributes": {
                    "options": [
                        "Left/Right Auto",
                        "Left-Left",
                        "Left-Center",
                        "Center-Center",
                        "Center-Right",
                        "Right-Right",
                        "Left-Right",
                        "Right-Left"
                    ],
                    "icon": "mdi:weather-dust",
                    "friendly_name": "Klimaanlage Horizontal"
                },
                "context": {
                    "id": "01HFQHV0ME8NHSBKA2K1GA1AAQ",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.510Z",
                "last_updated": "2023-11-20T23:42:50.510Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_indoor",
                "state": "24.2",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "°C",
                    "device_class": "temperature",
                    "friendly_name": "Klimaanlage"
                },
                "context": {
                    "id": "01HFQHV0Q2MQ4SNEM4RNGPD0JV",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.594Z",
                "last_updated": "2023-11-20T23:42:50.594Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_ip",
                "state": "192.168.1.155",
                "attributes": {
                    "friendly_name": "Klimaanlage Büro IP"
                },
                "context": {
                    "id": "01HFQHV0Q37VVKQ9KTV6MPXF4Q",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.595Z",
                "last_updated": "2023-11-20T23:42:50.595Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_operator_id",
                "state": "hassio-7-0218-499d-bee3-eab90d34215e",
                "attributes": {
                    "friendly_name": "Klimaanlage Büro Operator ID"
                },
                "context": {
                    "id": "01HFQHV0Q3GQNP0RW3HEH4GMBE",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.595Z",
                "last_updated": "2023-11-20T23:42:50.595Z"
            },
            {
                "entity_id": "sensor.klimaanlage_buro_outdoor",
                "state": "8.5",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "°C",
                    "device_class": "temperature",
                    "friendly_name": "Temperatur"
                },
                "context": {
                    "id": "01HFQJHX59PKS8NP4KHK8EXNEH",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:55:20.617Z",
                "last_updated": "2023-11-20T23:55:20.617Z"
            },
            {
                "entity_id": "sensor.buro_fernbedienung_battery",
                "state": "100",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "%",
                    "device_class": "battery",
                    "friendly_name": "Büro Fernbedienung"
                },
                "context": {
                    "id": "01HFQHW4WH7K72SNM2AS3PKGCS",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.633Z",
                "last_updated": "2023-11-20T23:43:27.633Z"
            },
            {
                "entity_id": "sensor.buro_fernbedienung_action",
                "state": "None",
                "attributes": {
                    "icon": "mdi:gesture-double-tap",
                    "friendly_name": "büro/fernbedienung Action"
                },
                "context": {
                    "id": "01HFQHW4WH5N3C69Q954SCVJW3",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.633Z",
                "last_updated": "2023-11-20T23:43:27.633Z"
            },
            {
                "entity_id": "sensor.buro_fernbedienung_action_duration",
                "state": "unknown",
                "attributes": {
                    "unit_of_measurement": "s",
                    "friendly_name": "büro/fernbedienung Action duration"
                },
                "context": {
                    "id": "01HFQHV36HZJW6MP067C460BBN",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.137Z",
                "last_updated": "2023-11-20T23:42:53.137Z"
            },
            {
                "entity_id": "update.buro_fernbedienung",
                "state": "off",
                "attributes": {
                    "auto_update": false,
                    "installed_version": "1107324829",
                    "in_progress": false,
                    "latest_version": "1107324829",
                    "release_summary": null,
                    "release_url": null,
                    "skipped_version": null,
                    "title": null,
                    "device_class": "firmware",
                    "entity_picture": "https://github.com/Koenkk/zigbee2mqtt/raw/master/images/logo.png",
                    "friendly_name": "büro/fernbedienung",
                    "supported_features": 1
                },
                "context": {
                    "id": "01HFQHW4WHTQQMYQVNV1GRXRPF",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.633Z",
                "last_updated": "2023-11-20T23:43:27.633Z"
            },
            {
                "entity_id": "switch.buro_lichtschalter",
                "state": "off",
                "attributes": {
                    "friendly_name": "Deckenlampe"
                },
                "context": {
                    "id": "01HFQHW4WH6SZ87ZA0CDZDKYVT",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.633Z",
                "last_updated": "2023-11-20T23:43:27.633Z"
            },
            {
                "entity_id": "select.buro_lichtschalter_power_on_behavior",
                "state": "unknown",
                "attributes": {
                    "options": [
                        "off",
                        "on",
                        "toggle",
                        "previous"
                    ],
                    "icon": "mdi:power-settings",
                    "friendly_name": "büro/lichtschalter Power-on behavior"
                },
                "context": {
                    "id": "01HFQHV368MARHT4HZMW1K3QZ2",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.128Z",
                "last_updated": "2023-11-20T23:42:53.128Z"
            },
            {
                "entity_id": "lock.buro_thermostat_child_lock",
                "state": "locked",
                "attributes": {
                    "friendly_name": "büro/thermostat Child lock",
                    "supported_features": 0
                },
                "context": {
                    "id": "01HFQHV415M1ESVE4136R1T0Q6",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.989Z",
                "last_updated": "2023-11-20T23:42:53.989Z"
            },
            {
                "entity_id": "number.buro_thermostat_deadzone_temperature",
                "state": "1",
                "attributes": {
                    "min": 0,
                    "max": 5,
                    "step": 1,
                    "mode": "auto",
                    "unit_of_measurement": "°C",
                    "icon": "mdi:thermometer",
                    "friendly_name": "büro/thermostat Deadzone temperature"
                },
                "context": {
                    "id": "01HFQHV416ZMTV7CXFNSWVYDR6",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.990Z",
                "last_updated": "2023-11-20T23:42:53.990Z"
            },
            {
                "entity_id": "number.buro_thermostat_max_temperature_limit",
                "state": "35",
                "attributes": {
                    "min": 0,
                    "max": 35,
                    "step": 1,
                    "mode": "auto",
                    "unit_of_measurement": "°C",
                    "icon": "mdi:thermometer-high",
                    "friendly_name": "büro/thermostat Max temperature limit"
                },
                "context": {
                    "id": "01HFQHV4161EMYZT47S5XF2AXH",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.990Z",
                "last_updated": "2023-11-20T23:42:53.990Z"
            },
            {
                "entity_id": "number.buro_thermostat_min_temperature_limit",
                "state": "1",
                "attributes": {
                    "min": 1,
                    "max": 5,
                    "step": 1,
                    "mode": "auto",
                    "unit_of_measurement": "°C",
                    "icon": "mdi:thermometer-low",
                    "friendly_name": "büro/thermostat Min temperature limit"
                },
                "context": {
                    "id": "01HFQHV4163NQJZM261SVESNHG",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.990Z",
                "last_updated": "2023-11-20T23:42:53.990Z"
            },
            {
                "entity_id": "number.buro_thermostat_local_temperature_calibration",
                "state": "-4.0",
                "attributes": {
                    "min": -30,
                    "max": 30,
                    "step": 0.1,
                    "mode": "auto",
                    "unit_of_measurement": "°C",
                    "device_class": "temperature",
                    "icon": "mdi:math-compass",
                    "friendly_name": "büro/thermostat Local temperature calibration"
                },
                "context": {
                    "id": "01HFQHV416261EMTK5N993M67W",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.990Z",
                "last_updated": "2023-11-20T23:42:53.990Z"
            },
            {
                "entity_id": "climate.buro_thermostat",
                "state": "off",
                "attributes": {
                    "hvac_modes": [
                        "off",
                        "heat"
                    ],
                    "min_temp": 5,
                    "max_temp": 35,
                    "target_temp_step": 1,
                    "preset_modes": [
                        "none",
                        "hold",
                        "program"
                    ],
                    "current_temperature": 18.5,
                    "temperature": 18,
                    "hvac_action": "idle",
                    "preset_mode": "hold",
                    "friendly_name": "Heizung",
                    "supported_features": 17
                },
                "context": {
                    "id": "01HFQHW4YCEZXDB117YMZ5JEJE",
                    "parent_id": "01HFQHW4X729YXJ8306W0N3C4R",
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.989Z",
                "last_updated": "2023-11-20T23:43:27.950Z"
            },
            {
                "entity_id": "sensor.buro_thermostat",
                "state": "AL",
                "attributes": {
                    "friendly_name": "büro/thermostat Sensor"
                },
                "context": {
                    "id": "01HFQHV41BYXSWM3BT99THE5AK",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.995Z",
                "last_updated": "2023-11-20T23:42:53.995Z"
            },
            {
                "entity_id": "select.buro_thermostat_sensor",
                "state": "AL",
                "attributes": {
                    "options": [
                        "IN",
                        "AL",
                        "OU"
                    ],
                    "friendly_name": "büro/thermostat Sensor"
                },
                "context": {
                    "id": "01HFQHV416XTN0VX0B594N14CQ",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.990Z",
                "last_updated": "2023-11-20T23:42:53.990Z"
            },
            {
                "entity_id": "sensor.buro_thermostat_program",
                "state": "unknown",
                "attributes": {},
                "context": {
                    "id": "01HFQHV41BP86PWVZ9CCSG6V81",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.137Z",
                "last_updated": "2023-11-20T23:42:53.995Z"
            },
            {
                "entity_id": "sensor.buro_fenster_status_battery",
                "state": "100",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "%",
                    "device_class": "battery",
                    "friendly_name": "Büro Fenster Sensor"
                },
                "context": {
                    "id": "01HFQHW4X8WNM223V9T9BF83BV",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.656Z",
                "last_updated": "2023-11-20T23:43:27.656Z"
            },
            {
                "entity_id": "binary_sensor.buro_fenster_status_contact",
                "state": "on",
                "attributes": {
                    "device_class": "window",
                    "icon": "mdi:window-closed-variant",
                    "friendly_name": "Fenster"
                },
                "context": {
                    "id": "01HFQHW4X729YXJ8306W0N3C4R",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.655Z",
                "last_updated": "2023-11-20T23:43:27.655Z"
            },
            {
                "entity_id": "sensor.buro_fenster_status_device_temperature",
                "state": "23",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "°C",
                    "device_class": "temperature",
                    "friendly_name": "büro/fenster/status Temperatur"
                },
                "context": {
                    "id": "01HFQHW4X7J03N7X7YGYW3ZSE0",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.655Z",
                "last_updated": "2023-11-20T23:43:27.655Z"
            },
            {
                "entity_id": "sensor.buro_fenster_status_voltage",
                "state": "3075",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "mV",
                    "device_class": "voltage",
                    "friendly_name": "büro/fenster/status Spannung"
                },
                "context": {
                    "id": "01HFQHW4X74CTJK0P8BQ5VMN1G",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.655Z",
                "last_updated": "2023-11-20T23:43:27.655Z"
            },
            {
                "entity_id": "sensor.buro_fenster_status_power_outage_count",
                "state": "13",
                "attributes": {
                    "friendly_name": "büro/fenster/status Power outage count"
                },
                "context": {
                    "id": "01HFQHW4X7H4JRDY4HH37YQBY1",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.655Z",
                "last_updated": "2023-11-20T23:43:27.655Z"
            },
            {
                "entity_id": "light.buro_lichtschalter",
                "state": "off",
                "attributes": {
                    "supported_color_modes": [
                        "onoff"
                    ],
                    "color_mode": null,
                    "friendly_name": "Deckenlampe",
                    "supported_features": 0
                },
                "context": {
                    "id": "01HFQHV36MDPTSJBRZ897Q2934",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:53.140Z",
                "last_updated": "2023-11-20T23:42:53.140Z"
            },
            {
                "entity_id": "camera.quantum_delta",
                "state": "idle",
                "attributes": {
                    "access_token": "5484deeae319b85de7243c10952ea198bfdef387a5559b1e7e1ec11afb687797",
                    "entity_picture": "/api/camera_proxy/camera.quantum_delta?token=5484deeae319b85de7243c10952ea198bfdef387a5559b1e7e1ec11afb687797",
                    "friendly_name": "Quantum Delta",
                    "supported_features": 0
                },
                "context": {
                    "id": "01HFQJD75DMPWDDJ6JAGXRAQ0Q",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.296Z",
                "last_updated": "2023-11-20T23:52:47.021Z"
            },
            {
                "entity_id": "media_player.esp32_audio_test_esphome_i2s_media_player",
                "state": "idle",
                "attributes": {
                    "volume_level": 1,
                    "is_volume_muted": false,
                    "device_class": "speaker",
                    "friendly_name": "ESPHome Audio Test ESPHome I2S Media Player",
                    "supported_features": 152077
                },
                "context": {
                    "id": "01HFQHV15RXZV92X5ZH6KCMP2P",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:51.064Z",
                "last_updated": "2023-11-20T23:42:51.064Z"
            },
            {
                "entity_id": "binary_sensor.esphome_audio_test_assist_in_verwendung",
                "state": "off",
                "attributes": {
                    "friendly_name": "ESPHome Audio Test Assist in Verwendung"
                },
                "context": {
                    "id": "01HFQHV0RFAGWM4P3WZQ7BPKPR",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.639Z",
                "last_updated": "2023-11-20T23:42:50.639Z"
            },
            {
                "entity_id": "select.esphome_audio_test_assist_pipeline",
                "state": "Local",
                "attributes": {
                    "options": [
                        "preferred",
                        "Home Assistant Cloud",
                        "Local"
                    ],
                    "friendly_name": "ESPHome Audio Test Assist-Pipeline"
                },
                "context": {
                    "id": "01HFQHV0RGBPEJCDQCCJNXCCSP",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.640Z",
                "last_updated": "2023-11-20T23:42:50.640Z"
            },
            {
                "entity_id": "select.esphome_audio_test_zu_ende_gesprochen_erkennung",
                "state": "default",
                "attributes": {
                    "options": [
                        "default",
                        "relaxed",
                        "aggressive"
                    ],
                    "friendly_name": "ESPHome Audio Test Zu Ende gesprochen Erkennung"
                },
                "context": {
                    "id": "01HFQHV0RG3YG5ZMBNN2S7AHNV",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:50.640Z",
                "last_updated": "2023-11-20T23:42:50.640Z"
            },
            {
                "entity_id": "switch.esp32_audio_test_use_wake_word",
                "state": "on",
                "attributes": {
                    "friendly_name": "ESPHome Audio Test Use Wake Word"
                },
                "context": {
                    "id": "01HFQHV145SM65GP9CQKSC3ESR",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:42:51.013Z",
                "last_updated": "2023-11-20T23:42:51.013Z"
            },
            {
                "entity_id": "switch.buro_werkbank_steckdose_slave",
                "state": "on",
                "attributes": {
                    "friendly_name": "Steckdose Werkbank"
                },
                "context": {
                    "id": "01HFQHW4XG1C6Z9JCWPRT5JSZN",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.664Z",
                "last_updated": "2023-11-20T23:43:27.664Z"
            },
            {
                "entity_id": "update.buro_werkbank_steckdose_slave",
                "state": "off",
                "attributes": {
                    "auto_update": false,
                    "installed_version": "16909577",
                    "in_progress": false,
                    "latest_version": "16909577",
                    "release_summary": null,
                    "release_url": null,
                    "skipped_version": null,
                    "title": null,
                    "device_class": "firmware",
                    "entity_picture": "https://github.com/Koenkk/zigbee2mqtt/raw/master/images/logo.png",
                    "friendly_name": "büro/werkbank/steckdose/slave",
                    "supported_features": 1
                },
                "context": {
                    "id": "01HFQHW4XGWRQW2AGA4JX9M1HK",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.664Z",
                "last_updated": "2023-11-20T23:43:27.664Z"
            },
            {
                "entity_id": "binary_sensor.buro_werkbank_anwesenheit_presence",
                "state": "off",
                "attributes": {
                    "device_class": "presence",
                    "friendly_name": "Anwesenheit"
                },
                "context": {
                    "id": "01HFQHW4Y2CFX9RBW5CSN7BH56",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.682Z",
                "last_updated": "2023-11-20T23:43:27.682Z"
            },
            {
                "entity_id": "sensor.buro_werkbank_anwesenheit_movement_type",
                "state": "none",
                "attributes": {
                    "friendly_name": "büro/werkbank/anwesenheit Movement type"
                },
                "context": {
                    "id": "01HFQHW4Y20HNXFWDWXS1FQ81V",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.682Z",
                "last_updated": "2023-11-20T23:43:27.682Z"
            },
            {
                "entity_id": "number.buro_werkbank_anwesenheit_detection_delay",
                "state": "60",
                "attributes": {
                    "min": 0,
                    "max": 600,
                    "step": 1,
                    "mode": "auto",
                    "unit_of_measurement": "s",
                    "friendly_name": "Abwesenheitsverzögerung"
                },
                "context": {
                    "id": "01HFQHW4Y1BP8G7Q41EWD4XJQ9",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.681Z",
                "last_updated": "2023-11-20T23:43:27.681Z"
            },
            {
                "entity_id": "number.buro_werkbank_anwesenheit_detection_range",
                "state": "600",
                "attributes": {
                    "min": 150,
                    "max": 600,
                    "step": 10,
                    "mode": "auto",
                    "friendly_name": "büro/werkbank/anwesenheit Detection range"
                },
                "context": {
                    "id": "01HFQHW4Y1B677TJA7K90E2W6K",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.681Z",
                "last_updated": "2023-11-20T23:43:27.681Z"
            },
            {
                "entity_id": "number.buro_werkbank_anwesenheit_radar_sensitivity",
                "state": "7",
                "attributes": {
                    "min": 0,
                    "max": 7,
                    "step": 1,
                    "mode": "auto",
                    "friendly_name": "büro/werkbank/anwesenheit Radar sensitivity"
                },
                "context": {
                    "id": "01HFQHW4Y1E0EVHKBTVG25PCVW",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.681Z",
                "last_updated": "2023-11-20T23:43:27.681Z"
            },
            {
                "entity_id": "number.buro_werkbank_anwesenheit_motion_sensitivity",
                "state": "0",
                "attributes": {
                    "min": 0,
                    "max": 7,
                    "step": 1,
                    "mode": "auto",
                    "friendly_name": "büro/werkbank/anwesenheit Motion sensitivity"
                },
                "context": {
                    "id": "01HFQHW4Y1RC5FD6YW04QM2Q5A",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.681Z",
                "last_updated": "2023-11-20T23:43:27.681Z"
            },
            {
                "entity_id": "sensor.buro_werkbank_anwesenheit_current_distance",
                "state": "264",
                "attributes": {
                    "unit_of_measurement": "cm",
                    "friendly_name": "büro/werkbank/anwesenheit Current distance"
                },
                "context": {
                    "id": "01HFQHW4Y251JJ7C4G49QBPEHB",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.682Z",
                "last_updated": "2023-11-20T23:43:27.682Z"
            },
            {
                "entity_id": "sensor.detection_distance",
                "state": "264.0",
                "attributes": {
                    "entity_id": "sensor.buro_werkbank_anwesenheit_current_distance",
                    "unit_of_measurement": "cm",
                    "icon": "mdi:chart-line-variant",
                    "friendly_name": "Werkbank Abstand"
                },
                "context": {
                    "id": "01HFQHW4YKWEJXFFEXF13F7VY6",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:43:27.699Z",
                "last_updated": "2023-11-20T23:43:27.699Z"
            }
        ]
    },
    {
        "aliases": [],
        "area_id": "garten",
        "name": "Garten",
        "picture": null,
        "devices": [],
        "services": [
            {
                "area_id": "garten",
                "configuration_url": null,
                "config_entries": [
                    "46f1e316d6999df8f44b03aaaa1c4946"
                ],
                "connections": [],
                "disabled_by": null,
                "entry_type": "service",
                "hw_version": null,
                "id": "5c3c4f4ac8fb63f72cc0c4658df9ffa0",
                "identifiers": [
                    [
                        "openweathermap",
                        "52.31419446-13.2146"
                    ]
                ],
                "manufacturer": "OpenWeather",
                "model": null,
                "name_by_user": null,
                "name": "OpenWeatherMap",
                "serial_number": null,
                "sw_version": null,
                "via_device_id": null
            }
        ],
        "entities": [
            {
                "entity_id": "sensor.klimaanlage_buro_outdoor",
                "state": "8.5",
                "attributes": {
                    "state_class": "measurement",
                    "unit_of_measurement": "°C",
                    "device_class": "temperature",
                    "friendly_name": "Temperatur"
                },
                "context": {
                    "id": "01HFQJHX59PKS8NP4KHK8EXNEH",
                    "parent_id": null,
                    "user_id": null
                },
                "last_changed": "2023-11-20T23:55:20.617Z",
                "last_updated": "2023-11-20T23:55:20.617Z"
            }
        ]
    }
]
**System Info (please complete the following information):** - VSCode - Chrome - v20.9 - 10.1
@shannonhochkins
Copy link
Owner

Hey man!

Thankyou for reporting the issue - I believe this is something I've introdcued as a feature for myself, but it's having unforseen side effects clearly - i've just released a new version of the core/components.

As for the hook useAreas now has an additional returned value called deviceEntities which is most likely the cause of your issue you're seeing as it will lookup related entities (children) of devices that are matched by default, i've now moved these to an individual property so you can optionally choose to use them or not

Hopefully this works for you!

@shannonhochkins
Copy link
Owner

@koriwi
Copy link
Collaborator Author

koriwi commented Nov 21, 2023

hey, it's not working as i expect, but i checked your commit and i think i can create a pr later. maybe after work :)
i just encountered a small error when setting the stuff up for developing.
i cloned your monorepo, build the core, and npm link it to my local dev dashboard. but i get this error

koriwi@MacBook-Pro-von-Kilian ha-dashboard % npm run dev                                     

> ha-dashboard@0.0.0 dev
> vite


  VITE v5.0.0  ready in 146 ms

  ➜  Local:   http://localhost:5173/local/ha-dashboard/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
✘ [ERROR] Could not resolve "@iconify/react"

    node_modules/@hakit/components/dist/hakit-components.es.js:16:27:
      16 │ import { Icon as dI } from "@iconify/react";~~~~~~~~~~~~~~~~

  You can mark the path "@iconify/react" as external to exclude it from the bundle, which will
  remove this error and leave the unresolved path in the bundle.

@shannonhochkins
Copy link
Owner

shannonhochkins commented Nov 21, 2023

Hey man, thanks that'd be great, unless we jump on a call to chat about the issue more because I might be misunderstanding the root issue!

Usually, this is because the project was built in different node / npm versions, I normally blow away build and package directories, and re-install and rebuild and re-link the workspace to rule out everything else

If all else fails, install the package manually on both sides, but I doubt that'll work

I will try checkout a new clone tomorrow and I'll see if I can replicate (it's 1030pm here now)

@koriwi
Copy link
Collaborator Author

koriwi commented Nov 21, 2023

ahhh ok. im more or less utc :) so you are utc +10? sounds like a cunt to me 😜
yeah we just need to find a spot where our timezones dont fight each other. if i can get it done easily, you can take a look at the pr and see if you get my point. if not, we can hop on a call!

@shannonhochkins
Copy link
Owner

ahhh ok. im more or less utc :) so you are utc +10? sounds like a cunt to me 😜
yeah we just need to find a spot where our timezones dont fight each other. if i can get it done easily, you can take a look at the pr and see if you get my point. if not, we can hop on a call!

Haha easy as mate

@koriwi
Copy link
Collaborator Author

koriwi commented Nov 21, 2023

Ok. i couldnt figure out until now how to npm link a package of a monorepo with peer dependencies in vite...
so i think i need your quick help. a call would be perfect! im awake for 3 more hours!

@shannonhochkins
Copy link
Owner

Yo, I can jump on a call in 45, but can you check your node and npm version please? It's looks to me like incorrect versions or mismatch versions, both in ha-component-kit and your dashboard must be using the same node version and npm version, and the npm version should be > 7

@koriwi
Copy link
Collaborator Author

koriwi commented Nov 21, 2023

i did. but i will check again :)
https://meet.google.com/edt-cktm-pef
will be there in 30min

@shannonhochkins
Copy link
Owner

I Just had a quick look tthrough the home assistant repository, they have this "memberships" method which looks pretty similar to what the useAreas hook is supposed to achieve

https://github.com/home-assistant/frontend/blob/0735705dd3f74e5474e20f330bb1816996ceeb2c/src/panels/config/areas/ha-config-area-page.ts#L92

Might be worth taking a look at this to determine if it has the same logic you're expecting to see!

@koriwi
Copy link
Collaborator Author

koriwi commented Nov 22, 2023

there it is

@shannonhochkins
Copy link
Owner

After I've merged your PR, I tested it, and noticed what i was missing in my example

for (const entity of entities) {
  if (entity.area_id) {
    if (entity.area_id === area.area_id) {
      matchedEntities.push(_entities[entity.entity_id]);
    }
  } else if (entity.device_id && matchedDevices.has(entity.device_id)) {
    // if the matched devices contain the device, it's definitely already part of the area
    // so we can add it as an indirect entity
    deviceEntities.push(_entities[entity.entity_id]);
    // HERE: im missing the check for tthe case where it does not have an area id but a matching device
  }
}

And to achieve that, i'd need to lookup the device rather than a simple check either way so what you proposed (as you expected) is correct - sorry it just took me a while to replicate the issue :)

@koriwi
Copy link
Collaborator Author

koriwi commented Nov 27, 2023

No worries! Also sorry for responding so late. My sister is moving and I'm helping. So I'm a bit more busy than usual

@shannonhochkins
Copy link
Owner

I'm re-opening this as I've just noticed that for myself, It doesn't appear to be working correctly - I noticed that when i displayed the counts for devices & entities, I'm getting some really obscure results.

For all of my areas, the "deviceEntities" more or less end up with basically every available device from my instance.

Are you seeing the same results?

@shannonhochkins
Copy link
Owner

After reading the code - it seems maybe you and I were confused with each other, but the current logic where it pushes items to the deviceEntities array, this should be removed, as currently the logic basically will add every entity to that array as there's technically no logic wrapped around it, it at the very least should only add it if it's within the area, however I don't think it's necessary as we do the same check on the next links down, I'll remove this for the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants