home-assistant/core

Error: Platform iotawatt does not generate unique IDs.

Aephir opened this issue · 22 comments

The problem

As the title says, I see this error in my logs.

What version of Home Assistant Core has the issue?

core-2023.2.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

IoTaWatt

Link to integration documentation on our website

https://www.home-assistant.io/integrations/iotawatt

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:540
Integration: Sensor (documentation, issues)
First occurred: 16:51:03 (3 occurrences)
Last logged: 16:51:03

Platform iotawatt does not generate unique IDs. ID 8CCE4EF8DE4C-input-1-WattHours already exists - ignoring sensor.iotawatt_input_1_wh
Platform iotawatt does not generate unique IDs. ID 8CCE4EF8DE4C-input-2-WattHours already exists - ignoring sensor.iotawatt_input_2_wh
Platform iotawatt does not generate unique IDs. ID 8CCE4EF8DE4C-input-3-WattHours already exists - ignoring sensor.iotawatt_input_3_wh


### Additional information

_No response_

Hey there @gtdiehl, @jyavenard, mind taking a look at this issue as it has been labeled with an integration (iotawatt) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of iotawatt can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign iotawatt Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


iotawatt documentation
iotawatt source
(message by IssueLinks)

I'm betting related to the known breaking change for IoTaWatt
https://www.home-assistant.io/blog/2023/02/01/release-20232/#breaking-changes

Yeah, tried multiple ways to remove, and can't seem to either. Including completely removing the integration and adding it back. I'll watch here for updates.

I am also having this problem. It looks like it's specifically for IoTaWatt configured "outputs". My "inputs" are correctly creating unique identifiers. This is important because i can't rename my IoTaWatt outputs in HA until they get a unique ID.

has there been any progress with this? I have the same issue, all the inputs show up, but not my outputs. Same messages in my logs regarding the unique IDs

Would love it if there could be a solution to this item.

Hi! Indeed it looks like the reason for the output to not show is because they don't have unique IDs.

I created a "Home" output in the IoTaWatt UI with the sum of my phases:

image
image

When I added the integration the "Home" entity is missing in the integration UI:

image

But when I go to the global entities UI in /config/entities is see:

image

And clicking on it and trying to configure it I get:

image

The funny thing is that the container I'm running Home Assistant shows warnings but for other input sensors:

2023-04-09 00:11:18.448 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-1-WattHours already exists - ignoring sensor.main_black_wh
2023-04-09 00:11:18.459 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-2-WattHours already exists - ignoring sensor.main_red_wh
2023-04-09 00:11:18.461 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-3-WattHours already exists - ignoring sensor.t2_black_wh
2023-04-09 00:11:18.462 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-4-WattHours already exists - ignoring sensor.t2_red_wh
2023-04-09 00:11:18.464 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-5-WattHours already exists - ignoring sensor.t3_black_wh
2023-04-09 00:11:18.464 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-6-WattHours already exists - ignoring sensor.t3_red_wh
2023-04-09 00:11:18.465 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-7-WattHours already exists - ignoring sensor.tb_wh
2023-04-09 00:11:18.466 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-11-WattHours already exists - ignoring sensor.oven_wh
2023-04-09 00:11:18.466 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-12-WattHours already exists - ignoring sensor.washing_red_wh
2023-04-09 00:11:18.467 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-13-WattHours already exists - ignoring sensor.washing_black_wh
2023-04-09 00:11:18.468 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-14-WattHours already exists - ignoring sensor.water_heater_wh

No logs for the output Home sensor though.

Despite all this, I was able to configure the Energy dashboard (although not sure if it is working correctly):

image

I enabled the debug log of the integration and I can see clearly that the outputs are being fetched:

2023-04-09 00:55:12.061 DEBUG (MainThread) [iotawattpy.connection] URL:

    http://192.168.10.13/status?inputs=yes&outputs=yes

2023-04-09 00:55:12.148 DEBUG (MainThread) [iotawattpy.iotawatt] IOResults:
{
    'inputs': [
        {'Hz': 60.02048, 'Vrms': 123.0277, 'channel': 0, 'phase': 0.74},
        {
            'Pf': 0.938114,
            'Watts': '170',
            'channel': 1,
            'lastphase': -0.44,
            'phase': 0.3,
            'reversed': True,
        },
        {
            'Pf': 0.933171,
            'Watts': '943',
            'channel': 2,
            'lastphase': -0.44,
            'phase': 0.3,
        },
        {
            'Pf': 0,
            'Watts': ' 0',
            'channel': 3,
            'lastphase': -0.04,
            'phase': 0.7,
        },
        {
            'Pf': 0.959655,
            'Watts': '267',
            'channel': 4,
            'lastphase': -0.04,
            'phase': 0.7,
        },
        {
            'Pf': 0.686277,
            'Watts': '25',
            'channel': 5,
            'lastphase': -0.04,
            'phase': 0.7,
            'reversed': True,
        },
        {
            'Pf': 0.776893,
            'Watts': '69',
            'channel': 6,
            'lastphase': -0.04,
            'phase': 0.7,
        },
        {
            'Pf': 0.821342,
            'Watts': '341',
            'channel': 7,
            'lastphase': 0.36,
            'phase': 1.1,
        },
        {
            'Pf': 0,
            'Watts': ' 0',
            'channel': 11,
            'lastphase': 0.36,
            'phase': 1.1,
        },
        {
            'Pf': 0,
            'Watts': ' 0',
            'channel': 12,
            'lastphase': 0.36,
            'phase': 1.1,
        },
        {
            'Pf': 0,
            'Watts': ' 0',
            'channel': 13,
            'lastphase': 0.36,
            'phase': 1.1,
        },
        {
            'Pf': 0,
            'Watts': ' 0',
            'channel': 14,
            'lastphase': 0.36,
            'phase': 1.1,
        },
    ],
    'outputs': [{'name': 'Home', 'units': 'Watts', 'value': 1112.797}],
}

2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 0 - Name: Reference
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 1 - Name: Main_Black
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 2 - Name: Main_Red
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 3 - Name: T2_Black
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 4 - Name: T2_Red
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 5 - Name: T3_Black
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 6 - Name: T3_Red
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 7 - Name: TB
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 11 - Name: Oven
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 12 - Name: Washing_Red
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 13 - Name: Washing_Black
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] In: Channel: 14 - Name: Water_Heater
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] Out: Name: Home
2023-04-09 00:58:12.229 DEBUG (MainThread) [iotawattpy.iotawatt] Sen:

  [
      "Reference.volts",
      "Main_Black.watts",
      "Main_Red.watts",
      "T2_Black.watts",
      "T2_Red.watts",
      "T3_Black.watts",
      "T3_Red.watts",
      "TB.watts",
      "Oven.watts",
      "Washing_Red.watts",
      "Washing_Black.watts",
      "Water_Heater.watts",
      "Home.watts"
  ]

(Pretty printing added)

So, it looks like is just an issue with the integration.

What is really the problem of generating UUID? I think that (device_name, input number) is a perfectly acceptable seed for a UUID. Is there a limitation I'm not seeing?

I'll try to fiddle with the integration to see if I can identify anything.

So, I did found the unique id here:

if data.getType() == "Input":

As shown, outputs aren't assigned a unique ID. Why? No idea. So I changed that code to this:

    def __init__(
        self,
        coordinator: IotawattUpdater,
        key: str,
        entity_description: IotaWattSensorEntityDescription,
    ) -> None:
        """Initialize the sensor."""
        super().__init__(coordinator=coordinator)

        self._key = key
        data = self._sensor_data

        type_ = data.getType()
        _LOGGER.error(f'#### FOUND TYPE: {type_}')

        if type_ == "Input":
            self._attr_unique_id = (
                f"{data.hub_mac_address}-input-{data.getChannel()}-{data.getUnit()}"
            )
        elif type_ == "Output":
            self._attr_unique_id = data.getSensorID()

        _LOGGER.error(f'#### UNIQUE ID: {self._attr_unique_id}')
        self.entity_description = entity_description

Note to self: Why data.getSensorID() isn't used for Inputs?

And now the output entities are showing in the integration:

image

But.... here is the interesting thing. Look at the logging I put in place for debugging. This is what Home Assistant logs:

2023-04-09 01:52:58.632 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.636 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-0-Volts
2023-04-09 01:52:58.637 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.638 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-1-Watts
2023-04-09 01:52:58.640 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.641 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-1-WattHours
2023-04-09 01:52:58.642 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.644 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-1-WattHours
2023-04-09 01:52:58.645 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.646 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-2-Watts
2023-04-09 01:52:58.648 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.649 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-2-WattHours
2023-04-09 01:52:58.650 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.651 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-2-WattHours
2023-04-09 01:52:58.653 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.654 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-3-Watts
2023-04-09 01:52:58.655 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.656 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-3-WattHours
2023-04-09 01:52:58.658 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.659 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-3-WattHours
2023-04-09 01:52:58.660 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.661 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-4-Watts
2023-04-09 01:52:58.663 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.664 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-4-WattHours
2023-04-09 01:52:58.665 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.666 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-4-WattHours
2023-04-09 01:52:58.667 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.667 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-5-Watts
2023-04-09 01:52:58.668 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.669 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-5-WattHours
2023-04-09 01:52:58.670 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.671 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-5-WattHours
2023-04-09 01:52:58.671 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.672 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-6-Watts
2023-04-09 01:52:58.673 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.673 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-6-WattHours
2023-04-09 01:52:58.674 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.674 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-6-WattHours
2023-04-09 01:52:58.675 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.675 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-7-Watts
2023-04-09 01:52:58.676 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.676 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-7-WattHours
2023-04-09 01:52:58.677 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.677 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-7-WattHours
2023-04-09 01:52:58.678 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.678 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-11-Watts
2023-04-09 01:52:58.678 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.679 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-11-WattHours
2023-04-09 01:52:58.679 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.680 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-11-WattHours
2023-04-09 01:52:58.680 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.681 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-12-Watts
2023-04-09 01:52:58.681 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.681 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-12-WattHours
2023-04-09 01:52:58.682 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.682 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-12-WattHours
2023-04-09 01:52:58.683 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.683 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-13-Watts
2023-04-09 01:52:58.684 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.684 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-13-WattHours
2023-04-09 01:52:58.684 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.685 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-13-WattHours
2023-04-09 01:52:58.685 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.686 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-14-Watts
2023-04-09 01:52:58.686 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.686 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-14-WattHours
2023-04-09 01:52:58.687 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 01:52:58.687 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-14-WattHours
2023-04-09 01:52:58.687 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Output
2023-04-09 01:52:58.688 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301_Output_Home
2023-04-09 01:52:58.688 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Output
2023-04-09 01:52:58.688 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301_Output_Home.wh
2023-04-09 01:52:58.689 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Output
2023-04-09 01:52:58.689 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301_Output_Home.wh_last
2023-04-09 01:52:58.690 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-1-WattHours already exists - ignoring sensor.main_black_wh
2023-04-09 01:52:58.691 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-2-WattHours already exists - ignoring sensor.main_red_wh
2023-04-09 01:52:58.692 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-3-WattHours already exists - ignoring sensor.t2_black_wh
2023-04-09 01:52:58.692 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-4-WattHours already exists - ignoring sensor.t2_red_wh
2023-04-09 01:52:58.693 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-5-WattHours already exists - ignoring sensor.t3_black_wh
2023-04-09 01:52:58.694 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-6-WattHours already exists - ignoring sensor.t3_red_wh
2023-04-09 01:52:58.695 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-7-WattHours already exists - ignoring sensor.tb_wh
2023-04-09 01:52:58.695 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-11-WattHours already exists - ignoring sensor.oven_wh
2023-04-09 01:52:58.696 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-12-WattHours already exists - ignoring sensor.washing_red_wh
2023-04-09 01:52:58.696 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-13-WattHours already exists - ignoring sensor.washing_black_wh
2023-04-09 01:52:58.697 ERROR (MainThread) [homeassistant.components.sensor] Platform iotawatt does not generate unique IDs. ID AC0BFBDF0301-input-14-WattHours already exists - ignoring sensor.water_heater_wh

Sooooo the error messages about "Platform iotawatt does not generate unique IDs." is not really that it doesn't generate an unique ID, is that the sensor class for each -WattHours is being instantiated twice. Note that this doesn't happen with other inputs.

I'll try to continue identifying what's going on...

I did found @gtdiehl custom component for IoTaWatt, and it does contains the fix I found before:

https://github.com/gtdiehl/iotawatt_ha/blob/395e4e776a56f1630f84f57b9b1fbcdb016db98d/custom_components/iotawatt/sensor.py#L184

So it seems like the Home Assistant core integration is maybe missing some code. I'll compare both and post here what I found.

I was able to identify a change relevant to the WattHours entities:

image

I'll test the changes and make a PR if they work as expected.

EDIT: The above change is instantiating a IotaWattAccumulatingSensor, which was removed since the integrators were added. No idea then, I'll keep digging.

So, I did found the issue with the non unique identifiers.

The issue looks like iotawattpy is returning several "energy" sensors for each input or output:

https://github.com/gtdiehl/iotawattpy/blob/c7584058676aaebcbc95e8d0f647ba76c8de37c8/iotawattpy/iotawatt.py#L128

When the Home Assistant integration runs, the sensors are created here:

async_add_entities(_create_entity(key) for key in coordinator.data["sensors"])

The value of coordinator.data["sensors"] is, in my case:

{
    'input_0': <iotawattpy.sensor.Sensor object at 0x7f1fc37c62c0>, 
    'input_1': <iotawattpy.sensor.Sensor object at 0x7f1fc297ac80>, 
    'input_1_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297ad10>, 
    'input_1_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297b6a0>, 
    'input_2': <iotawattpy.sensor.Sensor object at 0x7f1fc297b640>, 
    'input_2_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297b670>, 
    'input_2_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297b730>, 
    'input_3': <iotawattpy.sensor.Sensor object at 0x7f1fc297b820>, 
    'input_3_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297b7c0>, 
    'input_3_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297b880>, 
    'input_4': <iotawattpy.sensor.Sensor object at 0x7f1fc297b1c0>, 
    'input_4_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297ae90>, 
    'input_4_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297b8b0>, 
    'input_5': <iotawattpy.sensor.Sensor object at 0x7f1fc297b8e0>, 
    'input_5_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297baf0>, 
    'input_5_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297ba60>, 
    'input_6': <iotawattpy.sensor.Sensor object at 0x7f1fc297bb20>, 
    'input_6_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bb50>, 
    'input_6_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bb80>, 
    'input_7': <iotawattpy.sensor.Sensor object at 0x7f1fc297bbb0>, 
    'input_7_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bbe0>, 
    'input_7_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bc10>, 
    'input_11': <iotawattpy.sensor.Sensor object at 0x7f1fc297bc40>, 
    'input_11_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bc70>, 
    'input_11_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bca0>, 
    'input_12': <iotawattpy.sensor.Sensor object at 0x7f1fc297bcd0>, 
    'input_12_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bd00>, 
    'input_12_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bd30>, 
    'input_13': <iotawattpy.sensor.Sensor object at 0x7f1fc297bd60>, 
    'input_13_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bd90>, 
    'input_13_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bdc0>, 
    'input_14': <iotawattpy.sensor.Sensor object at 0x7f1fc297bdf0>, 
    'input_14_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297be20>, 
    'input_14_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297be50>, 
    'output_Home': <iotawattpy.sensor.Sensor object at 0x7f1fc297b610>, 
    'output_Home_total_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297beb0>, 
    'output_Home_energy': <iotawattpy.sensor.Sensor object at 0x7f1fc297bee0>
}

And here comes the funny part:

2023-04-09 16:07:01.950 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 16:07:01.950 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND KEY: input_13_total_energy
2023-04-09 16:07:01.950 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-13-WattHours
2023-04-09 16:07:01.951 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND TYPE: Input
2023-04-09 16:07:01.951 ERROR (MainThread) [custom_components.iotawatt.sensor] #### FOUND KEY: input_13_energy
2023-04-09 16:07:01.951 ERROR (MainThread) [custom_components.iotawatt.sensor] #### UNIQUE ID: AC0BFBDF0301-input-13-WattHours

So, in my case, keys input_13_total_energy and input_13_energy both generate the ID AC0BFBDF0301-input-13-WattHours, thus creating the error message shown.

It looks like the algorithm is deterministic (not sure though), and *_total_energy is iterated first. So in Home Assistant the *.wh sensors are actually mapped to the *_total_energy entry and not the *_energy entry, which is then lost and ignored.

That's is what's happening, but not sure how to fix it. I could simply improve the ID generation to account for this fact, and create more sensors, or just filter explicitly out either *_total_energy or *_energy entries if there is a reason for this.

@gtdiehl you're the expert, if you have any suggestion I can implement it.

I implemented a fix for this issue (both repeating IDs and outputs not showing). Its a one liner, but it has some implications:

  • Inputs entities will be renamed.
  • Entities for *_energy entries will appear with the suffix *.wh_last

It looks like the original author made an assumption, that using the channel is a more unique ID than the name for inputs, and by doing this they forgot the outputs. It works quite good, but if this isn't the direction please let me know.

PR #91141 was opened. The change is super simple:

image

I don't know if I'll survive Home Assistant merge bureaucracy, but there it is.

Love your work @carlos-jenkins

The official integration isn’t missing some changes. It’s a conscious decision as in their mind, the iotawatt outputs do not satisfy the requirements of being unique.

See #86834 (comment)

Thanks @jyavenard that gives me a lot of context.

So, I see there is a lot of politics here.

In the meantime I need a working integration. I just published the code of the integration with the fix here if anyone needs it:

https://github.com/kuralabs/iotawatt_ha

To install, go to your config directory and execute the following command:

mkdir -p custom_components
cd custom_components
git clone --branch 1.0.0 --depth 1 https://github.com/kuralabs/iotawatt_ha.git iotawatt

@carlos-jenkins thank you so much for this. I was getting so frustrated that some of my iotawatt sensors were on their own. Is there a way to force a UUID on these so that we can manage them from the UI and change their friendly names and assign them to an area? For any of my template sensors I just use an online UUID generator to assign one in the configuration.yaml and while I know that isn't recommended it's nice to actually have the option.

Hi guys, I've followed the above steps from @carlos-jenkins: ran that code from the HA config directory on my NAS (Docker install) and I'm not having any luck. Following executing the code I reload the integration in HA, and also tried completing restarting HA. In both instances I get the below error appear on the integration's panel on the HA Integration screen... it'll temporarily revert to 'Initializing...' while it seemingly tries again, but then reiterate the error. The log suggests it occurs 5 times in that initial burst after restarting. Any ideas?

Retrying setup: 'NoneType' object has no attribute 'status_code'

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Aephir commented

On HA v2023.8.1 this issue persists.

Since the combination of HA rules/guidelines + IoTaWatt policy seemingly won't ever allow this to work properly, perhaps the integration should be removed from HA core?

There seems to be a custom integration now that does work and does not have this error (as far as I can tell? I haven't tried it myself).

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.