homeassistant-plant icon indicating copy to clipboard operation
homeassistant-plant copied to clipboard

Integration doesn't pickup sensor data

Open chrisb86 opened this issue 1 year ago • 10 comments

I used the integration with some ESPHome USB hubs where I defined every sensor by hand.

With the release of the bluetooth proxy functionality I migrated everything to bluetooth proxys and integrated the MiFlora sensors with the native integration.

The sensor values are fetched by home assistant and are displayed in the device overview.

Then I deleted all the plants and created them again via UI. I used the new sensor entities and the plants are created successfully but they dont use the sensor values. They are shown as unknown.

In the core.config_entities the correct sensor entities are stored.

I don't know how I could start debugging.

chrisb86 avatar Sep 08 '22 20:09 chrisb86

I'm experiencing similar issues. I've created 5 plants thus far, 2 have unknown for values. One does not have specific values. All of these values are present in the "base" sensor.

southwestflavorz avatar Sep 11 '22 20:09 southwestflavorz

Please enable debug log of the custom_components.plant integration.

Olen avatar Sep 12 '22 06:09 Olen

Somehow the wrong sensor is used for the plant. The entites with "miflora" in it where the entity ids when I integrated the sensors the old ESPhome way.

They were deleted and I searched in /config/.storage and couldn't find any references to the old sensors. I don't know, where the integration remembers the old entities and why it uses them.

2022-09-12 10:17:50.642 DEBUG (MainThread) [custom_components.plant] Setting up config entry 7ce9a3ca5abcacd91f13a925fe40c2bb: <homeassistant.config_entries.ConfigEntry object at 0x7f426708d080> 2022-09-12 10:17:51.035 DEBUG (MainThread) [custom_components.plant.number] {'plant_info': {'name': 'Kinderzimmer Bogenhanf', 'species': 'sansevieria zeylanica', 'temperature_sensor': 'sensor.plant_sensor_6db18c_temperature', 'moisture_sensor': 'sensor.plant_sensor_6db18c_moisture', 'conductivity_sensor': 'sensor.plant_sensor_6db18c_conductivity', 'illuminance_sensor': 'sensor.plant_sensor_6db18c_illuminance', 'search_for': 'sansevieria zeylanica', 'entity_picture': '', 'display_pid': 'Sansevieria Zeylanica', 'limits': {'max_moisture': 60, 'min_moisture': 20, 'max_illuminance': 100000, 'min_illuminance': 0, 'max_dli': 30, 'min_dli': 2, 'max_temperature': 40, 'min_temperature': 10, 'max_conductivity': 3000, 'min_conductivity': 500, 'max_humidity': 60, 'min_humidity': 20}}} 2022-09-12 10:17:51.386 DEBUG (MainThread) [custom_components.plant.sensor] {'plant_info': {'name': 'Kinderzimmer Bogenhanf', 'species': 'sansevieria zeylanica', 'temperature_sensor': 'sensor.plant_sensor_6db18c_temperature', 'moisture_sensor': 'sensor.plant_sensor_6db18c_moisture', 'conductivity_sensor': 'sensor.plant_sensor_6db18c_conductivity', 'illuminance_sensor': 'sensor.plant_sensor_6db18c_illuminance', 'search_for': 'sansevieria zeylanica', 'entity_picture': '', 'display_pid': 'Sansevieria Zeylanica', 'limits': {'max_moisture': 60, 'min_moisture': 20, 'max_illuminance': 100000, 'min_illuminance': 0, 'max_dli': 30, 'min_dli': 2, 'max_temperature': 40, 'min_temperature': 10, 'max_conductivity': 3000, 'min_conductivity': 500, 'max_humidity': 60, 'min_humidity': 20}}} 2022-09-12 10:17:51.387 INFO (MainThread) [custom_components.plant.sensor] Added external sensor for None sensor.plant_sensor_6db18c_illuminance 2022-09-12 10:17:51.425 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.kinderzimmer_bogenhanf_illuminance external sensor to sensor.miflora_c47c8d6db18c_illuminance 2022-09-12 10:17:51.426 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.kinderzimmer_bogenhanf_conductivity external sensor to sensor.miflora_c47c8d6db18c_conductivity 2022-09-12 10:17:51.426 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.kinderzimmer_bogenhanf_soil_moisture external sensor to sensor.miflora_c47c8d6db18c_moisture 2022-09-12 10:17:51.426 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.kinderzimmer_bogenhanf_temperature external sensor to sensor.miflora_c47c8d6db18c_temperature 2022-09-12 10:17:51.427 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.kinderzimmer_bogenhanf_ppfd_mol external sensor to sensor.kinderzimmer_bogenhanf_illuminance

chrisb86 avatar Sep 12 '22 08:09 chrisb86

Try to use the replace_sensor service call instead of removing and re-adding plants. HA is very insistent on restoring and reusing previous entities when a new sensor is added with the same entity id as a former one.

Olen avatar Sep 13 '22 06:09 Olen

I had this same issue and calling replace_sensor worked for me. Thanks!

alexiri avatar Sep 18 '22 15:09 alexiri

I'm having the same issue after renaming one of the plants' BLE integration. It used to be yucca and is now dracaena. I tried replacing the sensors, but get (debug logging is enabled and this is all that's shown):

Refuse to update non-plant entities: sensor.yucca_illuminance

...for all the sensor.yucca_ variants.

Relevant debug logs:

2022-09-27 17:18:24.926 DEBUG (MainThread) [custom_components.plant.number] {'plant_info': {'name': 'Dracaena', 'species': 'dracaena fragrans', 'temperature_sensor': 'sensor.dracaena_temperature', 'moisture_sensor': 'sensor.dracaena_moisture', 'conductivity_sensor': 'sensor.dracaena_conductivity', 'illuminance_sensor': 'sensor.dracaena_illuminance', 'search_for': 'Dracaena Fragrans', 'data_source': 'openplantbook', 'entity_picture': 'https://opb-img.plantbook.io/dracaena%20fragrans.jpg', 'display_pid': 'Dracaena fragrans', 'limits': {'max_moisture': 60, 'min_moisture': 15, 'max_illuminance': 50000, 'min_illuminance': 2000, 'max_dli': 23, 'min_dli': 10, 'max_temperature': 95, 'min_temperature': 50, 'max_conductivity': 1500, 'min_conductivity': 200, 'max_humidity': 85, 'min_humidity': 30}}}

2022-09-27 17:18:25.492 DEBUG (MainThread) [custom_components.plant.sensor] {'plant_info': {'name': 'Dracaena', 'species': 'dracaena fragrans', 'temperature_sensor': 'sensor.dracaena_temperature', 'moisture_sensor': 'sensor.dracaena_moisture', 'conductivity_sensor': 'sensor.dracaena_conductivity', 'illuminance_sensor': 'sensor.dracaena_illuminance', 'search_for': 'Dracaena Fragrans', 'data_source': 'openplantbook', 'entity_picture': 'https://opb-img.plantbook.io/dracaena%20fragrans.jpg', 'display_pid': 'Dracaena fragrans', 'limits': {'max_moisture': 60, 'min_moisture': 15, 'max_illuminance': 50000, 'min_illuminance': 2000, 'max_dli': 23, 'min_dli': 10, 'max_temperature': 95, 'min_temperature': 50, 'max_conductivity': 1500, 'min_conductivity': 200, 'max_humidity': 85, 'min_humidity': 30}}}
2022-09-27 17:18:25.492 INFO (MainThread) [custom_components.plant.sensor] Added external sensor for None sensor.dracaena_illuminance

2022-09-27 17:18:25.628 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.dracaena_illuminance_2 external sensor to sensor.yucca_illuminance
2022-09-27 17:18:25.629 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.dracaena_conductivity_2 external sensor to sensor.yucca_conductivity
2022-09-27 17:18:25.629 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.dracaena_soil_moisture external sensor to sensor.yucca_moisture
2022-09-27 17:18:25.629 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.dracaena_temperature_2 external sensor to sensor.yucca_temperature
2022-09-27 17:18:25.629 INFO (MainThread) [custom_components.plant.sensor] Setting sensor.dracaena_ppfd_mol external sensor to sensor.dracaena_illuminance_2

From the BLE integration:

image image

From the Plant Monitor integration:

image image

mdrichardson avatar Sep 28 '22 00:09 mdrichardson

If you get the "Refuse to update..." error, it probably means that you mix up the two entries in the service call.

  • meter_entity is the entity_id of the sensor that is part of the plant.
  • new_sensor is the entity_id of the physical sensor that you want the meter_entity to get its data from.

What I personally do, to make a clearer separation between them, is that all my physical sensors (e.g BLE-devices) have generic entity_ids like "sensor.ble_sensor_1_moisture", "sensor.ble_sensor_1_illumination", "sensor.ble_sensor_2_conductivity" etc. And all my plants sensors have entity_ids like "sensor.rose_moisture", "sensor.chili_conductivity" etc.

That way, if I need to replace a (physical) sensor, it is very easy to grasp the concept and use

service: plant.replace_sensor
data:
  meter_entity: sensor.rose_illumination
  new_sensor: sensor.ble_sensor_12_illumination

Olen avatar Sep 28 '22 05:09 Olen

I updated the README with the above example, which hopefully makes it a bit clearer.

Olen avatar Sep 28 '22 05:09 Olen

I had the same issue with also Miflora and bluetooth proxies. Solved it as you said using plant.replace_sensor and everything works perfectly.

renaiku avatar Sep 29 '22 12:09 renaiku

@Olen, that's much more clear. Thank you!

mdrichardson avatar Oct 03 '22 20:10 mdrichardson