{"id":1859,"date":"2024-06-03T12:35:13","date_gmt":"2024-06-03T11:35:13","guid":{"rendered":"https:\/\/ofalcao.pt\/blog\/?p=1859"},"modified":"2024-06-04T14:18:45","modified_gmt":"2024-06-04T13:18:45","slug":"controlling-lego-hubs-a-mqtt2pybricks-gateway","status":"publish","type":"post","link":"https:\/\/ofalcao.pt\/blog\/2024\/controlling-lego-hubs-a-mqtt2pybricks-gateway","title":{"rendered":"Controlling LEGO hubs: a mqtt2pybricks gateway"},"content":{"rendered":"<div class=\"seriesmeta\">This post is part 1 of 1 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/mqtt2pybricks-gateway\" class=\"series-373\" title=\"mqtt2pybricks gateway\">mqtt2pybricks gateway<\/a><\/div>\n<p>We finally moved to a new home. Not an apartment on a 6th floor with dozens of crazy and noisy neighbors but a real house with a garden and a garage.<\/p>\n\n\n\n<p>I also quit my job and I am taking a rest. So I finally have both time and opportunity to look into domotics.<\/p>\n\n\n\n<p>I installed <a href=\"https:\/\/www.openhab.org\/\">OpenHAB<\/a> on a Raspberry Pi and started adding &#8216;things&#8217; to get familiar with it. The first was a Nedis dehumidifier I bought a few months after moving &#8211; we moved to a place with its own micro-weather, lots of humidity, and my wife and the younger kid have allergies problems so I&#8217;m trying to keep humidity levels low.<\/p>\n\n\n\n<p>Although the dehumidifier has builtin wi-fi we were using it just on manual mode but since it was easy to integrate with OpenHAB I started with it.<\/p>\n\n\n\n<p>OpenHAB offers &#8216;bridges&#8217; for several types of devices. This dehumidifier is a Tuya device so I added a Tuya bridge and found that I could read humidity and temperature values even when the dehumidifier was in standby mode (previously, to know the humidity level of the room I needed to turn it on to be shown on the display and just humidity, no temperature readings).<\/p>\n\n\n\n<p>So I ordered two Tuya humidity+temperature sensors to monitor our bedroom and the #2 bedroom.<\/p>\n\n\n\n<p>And then I added a older humidifier to OpenHAB through an also older wi-fi power plug. The humidifier has a &#8216;mechanic&#8217; power switch so I left it always ON and control it from the power plug.<\/p>\n\n\n\n<p>And then the third humidifier. But this one has a &#8216;digital&#8217; power switch so you need to press it to turn it ON\/OFF. And no builtin wi-fi. So a fingerbot-like gadget was needed. I chose a <a href=\"https:\/\/www.switch-bot.com\/products\/switchbot-bot\">Switchbot Bot<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.switch-bot.com\/cdn\/shop\/products\/switchbot-bot-781957.jpg?w=840&#038;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<p>It is a Bluetooth BLE device, is supposed to be used with the SwitchBot Hub that works as a  wi-fi to BLE gateway but I found a <a href=\"https:\/\/github.com\/OpenWonderLabs\/SwitchBotAPI-BLE\/blob\/latest\/devicetypes\/bot.md\">description of its API<\/a> so used python to control it and created my own mqtt2switchbot gateway with a Raspberry Pi Zero 2W (using &#8216;bleak&#8217; and &#8216;pahoo-mqtt&#8217;) and adding a MQTT broker to my OpenHAB server.<\/p>\n\n\n\n<p>So I can control Bluetooth BLE devices from my domotics central.<\/p>\n\n\n\n<p>And LEGO Hubs are BLE devices.<\/p>\n\n\n\n<p>So the next obvious step was controlling LEGO from my domotics central \ud83d\ude00<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"seriesmeta\">This post is part 1  of 1 of \u00a0<a href=\"https:\/\/ofalcao.pt\/blog\/series\/mqtt2pybricks-gateway\" class=\"series-373\" title=\"mqtt2pybricks gateway\">mqtt2pybricks gateway<\/a><\/div><p>We finally moved to a new home. Not an apartment on a 6th floor with dozens of crazy and noisy neighbors but a real house with a garden and a garage. I also quit my job and I am taking a rest. So I finally have both time and opportunity to look into domotics. I &hellip; <a href=\"https:\/\/ofalcao.pt\/blog\/2024\/controlling-lego-hubs-a-mqtt2pybricks-gateway\" class=\"more-link\">Continuar a ler<span class=\"screen-reader-text\"> &#8220;Controlling LEGO hubs: a mqtt2pybricks gateway&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[38,371,191],"tags":[372,362],"series":[373],"class_list":["post-1859","post","type-post","status-publish","format-standard","hentry","category-ble","category-domotics","category-raspberry-pi-en","tag-openhab","tag-pybricks","series-mqtt2pybricks-gateway"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2Mhyv-tZ","_links":{"self":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/comments?post=1859"}],"version-history":[{"count":0,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/posts\/1859\/revisions"}],"wp:attachment":[{"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/media?parent=1859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/categories?post=1859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/tags?post=1859"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/ofalcao.pt\/blog\/wp-json\/wp\/v2\/series?post=1859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}