hellqvio86 / home_assistant_casambi

Home assistant Integration for Casambi Cloud lights
MIT License
25 stars 9 forks source link

Error on adding entity's #95

Closed LenPoppe closed 10 months ago

LenPoppe commented 1 year ago

Hi,

I'm getting an error an adding the entity's

Log: 2023-09-12 19:45:13.177 ERROR (MainThread) [homeassistant.components.binary_sensor] casambi: Not adding entity with invalid device info: Invalid device info {'default_manufacturer': 'Casambi', 'default_model': 'Casambi', 'identifiers': {('casambi', '######################')}, 'manufacturer': 'Casambi', 'model': 'CBU-TED (log)', 'name': '##############', 'sw_version': '26.40'} for 'casambi' config entry: device info needs to either describe a device, link to existing device or provide extra information.

I'm new to Hass so I don't now how to fix this, can you help me with this?

hellqvio86 commented 1 year ago

Can you please describe how to replicate the issue? Steps what you did.

For installing the addon pleas use hacs, it's stated how in the readme.

Depending on your setup I would suggest to use the new casambi-bt integration, it talks directly to the lights using Bluetooth ble. This project only supports cloud gateway, but the new addon does not support legacy firmware.

You can find a link to casambi-bt in the readme

LenPoppe commented 1 year ago

I followed all the steps described in the readme and installed the addon with hacs. I tested with the casambi API console and that seemed to work. When I check the log it looks like it's detecting my casambi devices but is not able to add them somewhow. Next step will be indeed to use the new casambi-bt integration. But then I need to upgrade the firmware first.

hellqvio86 commented 1 year ago

I wod recommend to go with direct connection, the app is not that stable that's my experience.

Anyway if you proceed with this integration can you enable debug logs and share the casambi and aiocasambi logs? 🙂

hellqvio86 commented 11 months ago

I got the same issue after updating my hone assistant to latest release, looks like the binary sensor is missing mandatory properties.

I am currently starved on time, so I don't have more time at the moment to look into the issue more deeply.

LenPoppe commented 11 months ago

I updated the firmware to evolution and integrated the casambi-bt. This is working fine! only one casambi relay that is not getting detected. With the scenes that are detected this relay is working... just still have to find out how to deactivate a scene, I'm only able to activate them in HA at the moment. Anyway big thx for your help!

hellqvio86 commented 11 months ago

Most people I know use homeassistant instead of scenes, so their happy with just being able to control the lights, turn on/off, change brightness, color etc.

So for instance in this integration is not implemented at all and my guess is that it's the same in order integration. That's need it's fullfilled by automation in either home assistant or in like nodered.

Superkikim commented 11 months ago

I updated the firmware to evolution and integrated the casambi-bt. This is working fine! only one casambi relay that is not getting detected. With the scenes that are detected this relay is working... just still have to find out how to deactivate a scene, I'm only able to activate them in HA at the moment. Anyway big thx for your help!

Hi. Can you be more specific on how you worked around this issue ? I have the same problem since latest HA update. My Casambi integration doesn't work anymore.

LenPoppe commented 11 months ago

I only updated my devices to evolution firmware and integrated https://github.com/lkempf/casambi-bt-hass/, this worked out of the box for me.

reda1978 commented 11 months ago

Also with an issue. I can't add the lights... entities not added but the log suggests there is the right one

casambi: Not adding entity with invalid device info: Invalid device info {'default_manufacturer': 'Casambi', 'default_model': 'Casambi', 'identifiers': {('casambi', 'fBOmbX0GwgvUzkZ3EMzsE7znzFkxo140-2d6bc78be8cc')}, 'manufacturer': 'Occhio', 'model': 'Mito sospeso', 'name': 'Mito sospeso 40', 'sw_version': '40.1'} for 'casambi' config entry: device info needs to either describe a device, link to existing device or provide extra information.

triumfas commented 10 months ago

Decided to convert HA docker image to VM and order bluetooth dongle. I hope I will have less issues with BT integration. Till it arrives - sticking to version 2023.8.4

hellqvio86 commented 10 months ago

Some users have their Fixure IDs added in:

CASAMBI_FIXTURE_IDS variable in https://github.com/hellqvio86/aiocasambi/blob/main/src/aiocasambi/consts.py

CASAMBI_FIXTURE_IDS = {
    2516: {"oem": "Vadsbo", "fixture_model": "LD220WCM_onoff", "type": "Luminaire"},
    4027: {"oem": "Casambi", "fixture_model": "CBU-PWM4 RGBW", "type": "Luminaire"},
    14235: {"oem": "AIMOTION", "fixture_model": "GLOW", "type": "Luminaire"},
}

Not saying it will solve the issue, but that's is a lookup which is used for not having to look up static values through the cloud api. Happy to accept PRs with new fixure ids.

hellqvio86 commented 10 months ago

Failing code must be this: https://github.com/hellqvio86/home_assistant_casambi/blob/master/custom_components/casambi/casambi/CasambiEntity.py#L40:

    def device_info(self) -> DeviceInfo:
        """Return device information about this Casambi Key Light."""
        device_info = DeviceInfo(
            identifiers={(DOMAIN, self.unit.unique_id)},
            name=self.unit.name,
            default_manufacturer="Casambi",
            manufacturer=self.unit.oem,
            default_model="Casambi",
            model=self.unit.fixture_model,
            sw_version=self.unit.firmware_version,
        )

        _LOGGER.debug(f"device_info called returning: {device_info} unit: {self.unit}")

        return device_info

Home assistant expects more information.

Bet via_deviceis needed like via_device=(hue.DOMAIN, self.api.bridgeid), in the exampel https://developers.home-assistant.io/docs/device_registry_index/

hellqvio86 commented 10 months ago

Looking at home assistants code https://github.com/home-assistant/core/blob/c4f562ff6afbd8f5f968e3d2cff8abd6a080ab48/homeassistant/helpers/device_registry.py#L69:

class DeviceInfo(TypedDict, total=False):
    """Entity device information for device registry."""

    configuration_url: str | URL | None
    connections: set[tuple[str, str]]
    default_manufacturer: str
    default_model: str
    default_name: str
    entry_type: DeviceEntryType | None
    identifiers: set[tuple[str, str]]
    manufacturer: str | None
    model: str | None
    name: str | None
    suggested_area: str | None
    sw_version: str | None
    hw_version: str | None
    via_device: tuple[str, str]

DEVICE_INFO_TYPES = {
    # Device info is categorized by finding the first device info type which has all
    # the keys of the device info. The link device info type must be kept first
    # to make it preferred over primary.
    "link": {
        "connections",
        "identifiers",
    },
    "primary": {
        "configuration_url",
        "connections",
        "entry_type",
        "hw_version",
        "identifiers",
        "manufacturer",
        "model",
        "name",
        "suggested_area",
        "sw_version",
        "via_device",
    },
    "secondary": {
        "connections",
        "default_manufacturer",
        "default_model",
        "default_name",
        # Used by Fritz
        "via_device",
    },
}

A variant of it: https://github.com/home-assistant/core/blob/c4f562ff6afbd8f5f968e3d2cff8abd6a080ab48/homeassistant/components/hunterdouglas_powerview/entity.py with connections.

For tuya: https://github.com/home-assistant/core/blob/c4f562ff6afbd8f5f968e3d2cff8abd6a080ab48/homeassistant/components/tuya/base.py#L147

hellqvio86 commented 10 months ago

Whats failing on the home assistant side is line 184 in https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/device_registry.py:

if device_info_type is None:
      raise DeviceInfoError(
          config_entry.domain,
          device_info,
          (
              "device info needs to either describe a device, "
              "link to existing device or provide extra information."
          ),
      )
triumfas commented 10 months ago

Some users have their Fixure IDs added in:

CASAMBI_FIXTURE_IDS variable in https://github.com/hellqvio86/aiocasambi/blob/main/src/aiocasambi/consts.py

CASAMBI_FIXTURE_IDS = {
    2516: {"oem": "Vadsbo", "fixture_model": "LD220WCM_onoff", "type": "Luminaire"},
    4027: {"oem": "Casambi", "fixture_model": "CBU-PWM4 RGBW", "type": "Luminaire"},
    14235: {"oem": "AIMOTION", "fixture_model": "GLOW", "type": "Luminaire"},
}

Not saying it will solve the issue, but that's is a lookup which is used for not having to look up static values through the cloud api. Happy to accept PRs with new fixure ids.

From Casambi app info combined with what you wrote, it should look like this for my lights:

8223: {"oem": "Casambi", "fixture_model": "bDW Driver (Dim/PushBUTTON)", "type": "Luminaire"} 239: {"oem": "Casambi", "fixture_model": "Xpress", "type": "Switch"} (Casambi remote control - might be not relevant)

Actual vendor is "Tridonic GmbH & Co KG". But my guess is that OEM is just integration/any text part.

hellqvio86 commented 10 months ago

Oem would be "Tridonic GmbH & Co KG" in this case, that value will show up in home assistant.

The control is not supported by the api (far as I know), so thats not relevant for this integrtion.

I have released a new version of the plugin, device info has been removed and via_device is set now. It passes the checks in my docker image and works on my bare metal home assistant server.

hellqvio86 commented 10 months ago

The new version lacks the previously mentioned fixture, I need to add it to aiocasambi when I have time, happy to accept pull requests.

triumfas commented 10 months ago

I can confirm it works for me too. Thank you so much for your time.

hellqvio86 commented 10 months ago

Thanks closing the issue then, please open a new issue it if it still persist 🙂