Really neat project!
I’ve been playing around a bit with home-assistant for the gateway and in the end it would be quite similar to your component. Just instead of getting data from BT it gets it from the gateway API.
I’ve been using HA for years, but only made my own “integration” done via MQTT so I’m not too familiar with native integrations
Do you think it would make sense to have the gateway a separate integration or do you think it could be added into yours?
The gateway api (http://history?time=<time-since-last-poll (optional)> returns data like this:
So all it would have to do is poll the gateway api at some defined interval, parse the data and publish the new states to HA.
As the gateway dns is RuuviGateway<2-last-bytes-of-mac> I think it would be possible to have HA auto-discover it, that’d be very cool and user friendly
Good question. I don’t know. The component I’ve been working on uses the domain “ruuvi” which would be nice to use for the GW as well. But on the other hand, there’s no point loading ble dependencies if the GW is purely network based. If that’s not a problem, it’s totally doable to keep them in the same integration
Making a component for HA is easy at first, but then I experienced a slowdown in the learning curve when it comes to testing and the details of some of the internals I could try to share the knowledge I’ve gathered so far.
Btw, I’ve created that Ruuvi Friends organisation in Github to be able to move faster with the Ruuvi related projects. In a lot of cases maintainers get busy and projects grind to a complete halt because PRs don’t get reviewed or merged. In an organisation other people can help and collaborate to get things forward.
If you’d like I could invite you to the org, and we could setup something together there for the GW, and go the same “route” as the previous component:
Start with a “manual” custom component
Set it up in HACS store
Move towards a full official integration
However I don’t have a GW, so I can’t test things myself.
I don’t see a problem with having the bluetooth dependencies there unless they cause problems for installs that does not need them. So I suggest we try to keep it as one component and see how it goes, we can always split it up later if needed :).
Sure throw in an invite :). I think that we would be cool to eventually have the project under http://github.com/ruuvi/ . Thoughts on the repo and combined integration @otso@lauri ?
Thanks @sergioisidoro for your contribution so far! If you haven’t already, you should receive your Gateway today.
All this sounds good to me. Like @io53 suggested, a combined integration could be a good way to start with and if needed, that can be split later. Development can be under the Ruuvi Friends repo for sure and we can discuss later if it’d make sense for all the parties to have it under the official Ruuvi organisation later.
I just received my gateway yesterday, and configured it to send sensor data to my local HA MQTT broker. There’s another thread here about using the pyscript add-on to process the events and feed them back into MQTT to take advantage of HA auto-discovery.
Question: since the gateway already has the code to send MQTT messages with the encoded data, would it be a reasonable approach to just add a configuration button for “Homeassistant (Auto-Discovery)” under the MQTT section in the web UI on the gateway, then use this flag to set the topic and message format, e.g.:
I posted a link to my Github repo with a working pyscript script to process the raw MQTT events and feed it back into the MQTT broker for Home Assistant. If you’re interested in checking it out, it’s in this thread, along with some great discussion and the original script that got me started.
I´m also eagerly waiting for official add-on for Home assistant My coding skills are pretty limited, so easy to use add-on would be really welcome. Hoping to see it some day
I could not wait anymore so I built a node-red function to parse and push config, status and state messages to home-assistant. Code is in Github. The part for parsing tag is taken from ruuvi lab RuuviLab | Node-RED Node
The function has a throtling which lets through ,essages 1/minute/tag. Config messages are resent every 10 minutes. Not sure that is ok, but looking other devices using mqtt discovery that should be ok…
Worst part was to get the gateway config set to send mqtt. The gateway config tries to be too easy ending up being hard to setup.
Would you please show me what to do to get the Ruuvi Gateway discovered by the MQTT integration? I followed your instructions in your Github and made the Ruuvitag MAC changes in “parsetag” function node and set up the MQTT broker information. But the Gateway does not show up under the MQTT integration. I have enabled auto-discovery in the MQTT broker. Oh, the “Ruuvi” and “send to ha” nodes show connected.
BTW, The MQTT broker is receiving messages from the Ruuvi Gateway when I listen to the ruuvi/# topic.
Can you see the config message being sent correctly for each tag/measurement_type? Should be in a topic like
homeassistant/sensor/ruuvitag_xxxxxxxxxxxx_type
MQTTexplorer is a good tool to see what messages are flowing in your broker.
Also did you check your HA config/integrations MQTT if you have the entities without devices. I did end up in this situation while developing the script. If I remember correctly I had to remove the “orphan” ruuvi entities before I got the devices shown correctly.
Sorry. Hard to give exact help with this info. Hope you get it running.
Can this flow listen to more than 1 Ruuvi Gateway? Instruction on how please.
How often does the Ruuvitag sensor broadcast it’s bluetooth data? Can that be changed?
How often does the Ruuvit Gateway broadcast it’s MQTT data? Can that be changed?
I see no reason why listening several gateways would not work.
That I am not sure. It depends on the firmware. I found this link to ruuvi lab which says.
The 2.5.9 firmware has 3 modes:
RAWv2-fast (broadcast every 1285ms, green LED blinks, theoretical battery life 4 years)
RAWv2-slow (broadcast every 6425ms, green LED blinks, theoretical battery life 6 years)
RAWv1-fast (broadcast every 1285ms, red LED blinks, theoretical battery life 4 years)
I did not find any info on how often the gateway sends the info. I have limited the node-red flow to send the info once / minute. This can be changed by changing this line
if (lastmsg+60<ms) {
The value 60 here is the number of seconds to wait before allowing the next message to pass thru for the device. Hmm… This should be a parameter… Maybe in next version
Would it be possible to get step by step instructions for installing the Gateway client package?
Have tried unsuccessfully install the package in HA OS terminal, Installed Pyscript in HACS, made pyscript integration and copied package files to python folder. None of these seems to do the trick…
Is there any plans to get official integration or HACS integration?
We are looking into how we could support RuuviTags in HA, either through the official Bluetooth Sensor integration or through Gateway and MQTT / HTTP. I cannot promise a schedule for the support yet.