Netatmo homeassistant.exceptions.HomeAssistantError: Entity id already exists error

Hi !

I have netatmo setup but when I start HA, I have the following error:

2018-12-20 10:37:44 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 344, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.netatmo_outdoor_temperature. Platform netatmo does not generate unique IDs

This is my configuration:

- platform: netatmo
  station: HOME
  modules:
    Indoor:
      - temperature
      - max_temp
      - min_temp
      - humidity
      - noise
      - pressure
      - co2
    Outdoor:
      - temperature
      - max_temp
      - min_temp
      - humidity

Home Assistant 0.84.5

Same issue for me in 0.84.5, 0.84.4 and 0.84 I think

Yep same issue for me since 0.84 upgrade. Is there anyway to remove them?

Same here on 0.84.6. I was thinking about something wrong on my setup. I will wait for further update.

Same here with all netatmo sensors.

The issue is still there with 0.86.3

Same error here with 0.87

same error here with 0.88.2

Issue still there with Home Assistant 0.89.1.

I’ve created an issue.

Hi i have fixed this bug in my instance.
Please, if someone can test my fix (Hass 0.92.1), ( @WhistleMaster ?)
I add the station’s name in unique id
in /homeassistant/components/netatmo/sensor.py

@@ -101,7 +101,7 @@
               else:
                   # Only create sensors for monitored properties
                   for variable in monitored_conditions:
-                        dev.append(NetAtmoSensor(data, module_name, variable, config.get(CONF_STATION)))
+                        dev.append(NetAtmoSensor(data, module_name, variable))
       except pyatmo.NoDevice:
           continue

@@ -121,7 +121,7 @@
               for variable in \
                       data.station_data.monitoredConditions(module_name):
                   if variable in SENSOR_TYPES.keys():
-                        dev.append(NetAtmoSensor(data, module_name, variable, config.get(CONF_STATION)))
+                        dev.append(NetAtmoSensor(data, module_name, variable))
                   else:
                       _LOGGER.warning("Ignoring unknown var %s for mod %s",
                                       variable, module_name)
@@ -139,14 +139,13 @@
class NetAtmoSensor(Entity):
   """Implementation of a Netatmo sensor."""

-    def __init__(self, netatmo_data, module_name, sensor_type, station):
+    def __init__(self, netatmo_data, module_name, sensor_type):
       """Initialize the sensor."""
       self._name = 'Netatmo {} {}'.format(module_name,
                                           SENSOR_TYPES[sensor_type][0])
       self.netatmo_data = netatmo_data
       self.module_name = module_name
       self.type = sensor_type
-        self.station_name = station
       self._state = None
       self._device_class = SENSOR_TYPES[self.type][3]
       self._icon = SENSOR_TYPES[self.type][2]
@@ -154,7 +153,7 @@
       self._module_type = self.netatmo_data. \
           station_data.moduleByName(module=module_name)['type']
       module_id = self.netatmo_data. \
-            station_data.moduleByName(station=self.station_name,module=module_name)['_id']
+            station_data.moduleByName(module=module_name)['_id']
       self._unique_id = '{}-{}'.format(module_id, self.type)

Seems to be fixed in 0.93.x but got another error:

2019-05-16 19:58:10 ERROR (SyncWorker_11) [homeassistant.components.netatmo.sensor] No Weather or HomeCoach devices found for Maison
2019-05-16 19:58:10 ERROR (SyncWorker_11) [homeassistant.components.netatmo.sensor] Module name: "XXX" not found

Could it be linked to your changes ?

EDIT: It is not fixed yet in fact.

upgrade in progress
there is an upgrade for lib pyatmo==1.11

for me the bug is not fixed

Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 357, in _async_add_entity
    raise HomeAssistantError(msg)
homeassistant.exceptions.HomeAssistantError: Entity id already exists: sensor.netatmo_indoor_noise. Platform netatmo does not generate unique IDs
2019-05-17 21:51:18 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 357, in _async_add_entity
    raise HomeAssistantError(msg)

new changes for 0.93.2 @WhistleMaster

 @@ -145,7 +145,7 @@
                     # Only create sensors for monitored properties
                     for condition in monitored_conditions:
                         dev.append(NetatmoSensor(
-                            data, module_name, condition.lower()))
+                            data, module_name, condition.lower(), config.get(CONF_STATION)))
 
         for module_name, _ in not_handled.items():
             _LOGGER.error('Module name: "%s" not found', module_name)
@@ -164,13 +164,14 @@
 class NetatmoSensor(Entity):
     """Implementation of a Netatmo sensor."""
 
-    def __init__(self, netatmo_data, module_name, sensor_type):
+    def __init__(self, netatmo_data, module_name, sensor_type, station):
         """Initialize the sensor."""
         self._name = 'Netatmo {} {}'.format(module_name,
                                             SENSOR_TYPES[sensor_type][0])
         self.netatmo_data = netatmo_data
         self.module_name = module_name
         self.type = sensor_type
+        self.station_name = station
         self._state = None
         self._device_class = SENSOR_TYPES[self.type][3]
         self._icon = SENSOR_TYPES[self.type][2]
@@ -178,8 +179,9 @@
         self._module_type = self.netatmo_data. \
             station_data.moduleByName(module=module_name)['type']
         module_id = self.netatmo_data. \
-            station_data.moduleByName(module=module_name)['_id']
+            station_data.moduleByName(station=self.station_name,module=module_name)['_id']
         self._unique_id = '{}-{}'.format(module_id, self.type)
+        _LOGGER.info('Module name: "%s" , unique_id: "%s"', module_name, self._unique_id)

i have adding a new log for debug

little warnings @WhistleMaster, your configuration not must be in auto mode :

station

    (string)(Optional)The name of the weather station. Needed if several stations are associated with the account.

Still have the issue with 0.93.2. This is my config:

- platform: netatmo
  station: HOME
  modules:
    Indoor:
      - temperature
      - max_temp
      - min_temp
      - humidity
      - noise
      - pressure
      - co2
    Outdoor:
      - temperature
      - max_temp
      - min_temp
      - humidity

could you sended your logs, example:

grep 'unique_id' home-assistant.log

It gives me an empty result. I don’t have the string ‘unique_id’ in the log file. Do I need to enabled more debug for some components ?

ok @WhistleMaster , it’s weird because my patch add this comment in log . Are you sure to have adding my patch in netatmo sensor.py ?

@maheus I’ve simply updated to HA 0.93.2 as I thought your patch was already merged on the git. If I understand correctly, I have to patch manually sensor.py, is that correct ?

Yes that’s it, you must patch manually for the moment (my patch was merged today in dev branch).
@WhistleMaster also could you add , the option: discovery: false in your conf:

netatmo:
  api_key: XXX
  secret_key: XXX
  username: XXX
  password: XXX
  discovery: false

I suspect that the auto config is conflicting with your conf