Mqtt (retained) sensors keep turning up

Continuing the discussion from Howto create battery alert without creating a template for every device:
I think i have found the unwanted and unconfigured sensors, they are originating from homeassistant, and not from my zwave-hub:

this is showing in the logs:

Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/cv_garage_actueel/config', ... (159 bytes))
homeassistant/sensor/cv_garage_actueel/config {
  "device_class": "sensor",
  "name": "CV Garage actueel",
  "state_topic": "homeassistant/sensor/cv_garage_actueel/state",
  "unit_of_measurement": "Watt"
}
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/tester_actueel/config', ... (153 bytes))
homeassistant/sensor/tester_actueel/config {
  "device_class": "sensor",
  "name": "Tester actueel",
  "state_topic": "homeassistant/sensor/tester_actueel/state",
  "unit_of_measurement": "Watt"
}
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/quooker_keuken_actueel/config', ... (169 bytes))
homeassistant/sensor/quooker_keuken_actueel/config {
  "device_class": "sensor",
  "name": "Quooker Keuken actueel",
  "state_topic": "homeassistant/sensor/quooker_keuken_actueel/state",
  "unit_of_measurement": "Watt"
}
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/corridor_motion_sensor_battery/config', ... (182 bytes))
homeassistant/sensor/corridor_motion_sensor_battery/config {
  "device_class": "sensor",
  "name": "Corridor motion sensor Battery",
  "state_topic": "homeassistant/sensor/corridor_motion_sensor_battery/state",
  "unit_of_measurement": "%"

continuing with all other battery events originating from your package i presume.

@NotoriousBDG
Why these first 3 sensors suddenly are published is beyond me. especially the /config is new to me, is that some default value in mqtt or in your package maybe?
At least i can now try to issue a more precise “null” command… --edit-- and have managed to do so successfully with:
mosquitto_pub -h ipaddress -p 1883 -u Username -P Password -t "homeassistant/sensor/tester_actueel/config" -r -n for each of them
:+1: thanks @NotoriousBDG —end-edit----

the end of this bit is, and watch the R1 turn into R0…:

Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/ipadred_battery/state', ... (2 bytes))
homeassistant/sensor/ipadred_battery/state 63
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/hue_dimmer_switch_1_battery/config', ... (176 bytes))
homeassistant/sensor/hue_dimmer_switch_1_battery/config {
  "device_class": "sensor",
  "name": "Hue dimmer switch 1 Battery",
  "state_topic": "homeassistant/sensor/hue_dimmer_switch_1_battery/state",
  "unit_of_measurement": "%"
}
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r1, m0, 'homeassistant/sensor/hue_dimmer_switch_1_battery/state', ... (3 bytes))
homeassistant/sensor/hue_dimmer_switch_1_battery/state 100
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r0, m0, 'macaddress/powerswitch-zwave/430ba8cf/usage', ... (3 bytes))
macaddress/powerswitch-zwave/430ba8cf/usage 0.8
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r0, m0, 'macaddress/energy-dsmr4/538d72d9/T2', ... (7 bytes))
macaddress/energy-dsmr4/538d72d9/T2 5690.15
Client mosqsub|28383-core-ssh received PUBLISH (d0, q0, r0, m0, 'macaddress/energy-dsmr4/538d72d9/L1Pimp', ... (5 bytes))
macaddress/energy-dsmr4/538d72d9/L1Pimp 0.039

I wonder if i wouldn’t be better off with something like force_update instead of the retain value, because the retain value creates false values also. (retaining a value while the sensor has changed but isnt updated)

Then again, im not sure i see how a force_update could be sent to a Mqtt publisher not being the homeassistant instance itself?
Ive added this configuration variable now and will see what happens, if anything. Will try and stop the retain value in the publishing Hub.

Those definitely aren’t from the battery package, but they could be from the automation I posted at Allow mqtt_statestream component the ability to include/exclude entities - #5 by NotoriousBDG. Since you commented there too, I suspect that is likely the culprit. If so, disable that automation, clear those topics again, then restart Home Assistant.

well of course they are!.
Ive tested that before, and since my setup is different from your use case (i only have one HA instance) i have put it aside.
I changed it a bit, with, as might be obvious right now, these 3 sensors, that where retained without me thinking about that. Only to show up after enabling the discovery: true again.

Pardon my stupidity, really sorry, but learning a lot here though…

Any thoughts on the force_update ? Or is that also only useful for publishers from the homeassistant instance, and not, as in my use case, for reading and force reading from another publisher.

Cheers,
Marius

Glad you hear you found the culprit.

I hadn’t heard of force_update before, so I’m not really sure how it would affect this use case. If you test it out, I’m interested in hearing your results.