Miflora Sensors Dups in Home Assistant #357
Replies: 7 comments 10 replies
-
Hi Alex, I understand that the idea is not to read all sensor from all room-assistant nodes at the same time, but for me it was convenient. Some of the sensor are on places that sometimes report well (because of distance, blocks, wall, interferences...) and others not, to the HA Pi that was the only one before with the classic xiaomi integration. I leave my flow below but, this is just "my workaround": [{"id":"773ae754.657078","type":"mqtt out","z":"fedb253d.698188","g":"9209262c.db8a58","name":"","topic":"","qos":"","retain":"","broker":"30ba6ef7.37e75a","x":1130,"y":120,"wires":[]},{"id":"2fc2d861.e83b3","type":"delay","z":"fedb253d.698188","g":"9209262c.db8a58","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":990,"y":120,"wires":[["773ae754.657078"]]},{"id":"42ee31b9.2e311","type":"switch","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Not restarted","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"offline","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":830,"y":120,"wires":[["2fc2d861.e83b3"]]},{"id":"4b1fe5e6.d945d4","type":"function","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Set Xiaomi topic","func":"msg.topic=msg.topic.replace(/^room-assistant\\/sensor\\/[a-z]*-/i, \"room-assistant/sensor/xiaomi-\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":80,"wires":[["42ee31b9.2e311"]]},{"id":"fac7d645.2e08b8","type":"function","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Set Xiaomi stuffs","func":"//Topic\nmsg.topic=msg.topic.replace(/^homeassistant\\/sensor\\/room-assistant\\/[a-z]*-/i, \"homeassistant/sensor/room-assistant/xiaomi-\")\n\n//In Payload\n//Name\nmsg.payload=msg.payload.replace(/\"name\":\"/ig,'\"name\":\"Xiaomi ')\n//Topics for data\nmsg.payload=msg.payload.replace(/room-assistant\\/sensor\\/[a-z]*-/gi,\"room-assistant/sensor/xiaomi-\")\n//id\nmsg.payload=msg.payload.replace(/\"unique_id\":\"room-assistant-[a-z]*-/i,'\"unique_id\":\"room-assistant-xiaomi-')\n//Identifiers\nmsg.payload=msg.payload.replace(/\"identifiers\":\"[a-z0-9]*/i,'\"identifiers\":\"Xiaomi')\n//Model\nmsg.payload=msg.payload.replace(/\"model\":\"[a-z0-9]*/i,'\"model\":\"Xiaomi')\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":630,"y":160,"wires":[["42ee31b9.2e311"]]},{"id":"81b3f850.9903f","type":"switch","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Only known","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"temperature","vt":"str"},{"t":"cont","v":"humidity","vt":"str"},{"t":"cont","v":"battery","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":430,"y":80,"wires":[["4b1fe5e6.d945d4"],["4b1fe5e6.d945d4"],["4b1fe5e6.d945d4"]]},{"id":"4c45fb21.547d94","type":"switch","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Only known","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"temperature","vt":"str"},{"t":"cont","v":"humidity","vt":"str"},{"t":"cont","v":"battery","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":430,"y":160,"wires":[["fac7d645.2e08b8"],["fac7d645.2e08b8"],["fac7d645.2e08b8"]]},{"id":"4af1468d.340738","type":"switch","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Not Xiaomi","property":"topic","propertyType":"msg","rules":[{"t":"regex","v":"^((?!xiaomi).)*$","vt":"str","case":true}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":80,"wires":[["81b3f850.9903f"]]},{"id":"329d64f1.e15b64","type":"switch","z":"fedb253d.698188","g":"9209262c.db8a58","name":"Not Xiaomi","property":"topic","propertyType":"msg","rules":[{"t":"regex","v":"^((?!xiaomi).)*$","vt":"str","case":true}],"checkall":"true","repair":false,"outputs":1,"x":270,"y":160,"wires":[["4c45fb21.547d94"]]},{"id":"58797c10.c7bedc","type":"mqtt in","z":"fedb253d.698188","g":"9209262c.db8a58","name":"room-sensors","topic":"room-assistant/sensor/#","qos":"2","datatype":"auto","broker":"30ba6ef7.37e75a","x":110,"y":80,"wires":[["4af1468d.340738"]]},{"id":"8b4974dc.6eca08","type":"mqtt in","z":"fedb253d.698188","g":"9209262c.db8a58","name":"room-entities","topic":"homeassistant/sensor/room-assistant/#","qos":"2","datatype":"auto","broker":"30ba6ef7.37e75a","x":110,"y":160,"wires":[["329d64f1.e15b64"]]},{"id":"30ba6ef7.37e75a","type":"mqtt-broker","name":"HA","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}] Cheers |
Beta Was this translation helpful? Give feedback.
-
Super! Thanks for this! I think another option is a sensor template that combines all instances in one? |
Beta Was this translation helpful? Give feedback.
-
hi @JesusRo Also, i wonder if room assistant will work in parallel with one of these:
I read somewhere that the room assistant locks Bluetooth of the device when it runs so not sure if these can run simultaneously? thanks, |
Beta Was this translation helpful? Give feedback.
-
Hey @alexbell62, Regarding the metrics of xiaomi sensors, I think each model/version reports differently. In instance, mine ones report temperature and humidity every 10 mins, and battery level every 30 if I remember correctly. The xiaomi sensor integration I was using before was xiaomi_bt (referenced also on room-assistant docs) and actually I had them both working together (in HASS.io) fine for a while but only BLE, never used active bluethoot scanning. You can give it a try |
Beta Was this translation helpful? Give feedback.
-
Huge thanks for this! Thanks for the custom component link. I also used in-built HA component before, this one: https://www.home-assistant.io/integrations/miflora/ Hmm, just not sure how to do it and where to start. |
Beta Was this translation helpful? Give feedback.
-
It's currently not implemented in room-assistant since I wasn't aware that this is a use case - so far I just assumed people would configure the Xiaomi Mi stuff on one instance only, whichever is the closest to the device. I wouldn't want to change the default behavior here, but I could imagine opening this up as a config option. Feel free to open a feature request for this! |
Beta Was this translation helpful? Give feedback.
-
I jumped the gun 8-) and just pushed a PR (#362) that swaps |
Beta Was this translation helpful? Give feedback.
-
Hi,
Is there a way to set up Xiaomi Miflora sensors in room assistant config on multiple raspberry pi zero w the way so its not duplicated in home assistant?
Currently after configuring miflora sensors on a few raspberry pi zero ws im getting these duplicates in home assistant:
sensor.avocado_humidity
sensor.avocado_humidity_2
sensor.avocado_humidity_3
sensor.avocado_humidity_4
What is the best way to combine them into one sensor and is there a way to set up the room assistant config to do it?
Thanks.
Alex
Beta Was this translation helpful? Give feedback.
All reactions