SwitchBot in Openluup (was: Smaller and local alternative to MicroBots)
-
Ok, must say. Before I was using tasmota. But since I discovered esphome.io that is now my primary start for automation devices. So easy, so cheap and so reliable!
Easily manageable via home assistant addon... -
Ok, must say. Before I was using tasmota. But since I discovered esphome.io that is now my primary start for automation devices. So easy, so cheap and so reliable!
Easily manageable via home assistant addon... -
@sender I'll flash a new device and try it. I must say I'm ok with tasmota, since I'm using mqtt and I already know the message format, but I'm here to test new things, after all.
@therealdb using esphome and in my case together with homeassistant make mqtt hassle unneeded. It automatically includes the homeassistant api. If the esphome device is part of the same subnet it is auto discovered and entities are auto populated in hass. If not in same subnet need to manually add an esphome integration per device (ip address). Other thing you need to take care of then it is "pinging" devices instead of mdns (all in manual but good to know) for "online status". I have in 1 week around 15 wifi D1 minis as sensors, nextion displays (touchscreen "wallmote quad" but cheaper and better), 4 and 8 relay boards for sprinkler, etc etc. So easy!
-
Yep, I underestimated those cheap wifi devices, until I started to buy many of them, just for testing. While I prefer Zwave for "serious" work, since I have 3 access points on my home (and one outside), Wifi coverage is really good and their traffic is very low anyway, so I'm somewhat sold, especially for fancy sensors and/or difficult to reach zones for my Zwave mesh.
-
So, mission accomplished. I wrote a very basic node app running on my Linux box. I'm using this library because I'm more comfortable with Javascript than Pyton: https://github.com/futomi/node-switchbot
But it's missing the ability to use password protected SwitchBots, so I will probably patch it or move to the Python one, depending on how many spare time I have in the coming weeks.
Node server is very simple:
const http = require('http'); const url = require('url'); const Switchbot = require('node-switchbot'); const requestListener = function (req, res) { const queryObject = url.parse(req.url, true).query; res.writeHead(200); let device = null; if (queryObject == undefined || queryObject.id == undefined) return res.end('Please specify an id'); const switchbot = new Switchbot(); switchbot.discover({ id: queryObject.id, quick: true }).then((device_list) => { if (device_list == undefined || device_list.length == 0) { console.log('#device: notfound'); res.end('no device'); } device = device_list[0]; console.log('#devicefound: ' + device.modelName + ' (' + device.address + ')'); return true; //device.connect(); }).then(() => { console.log('#device:press'); return device.press(); }).then(() => { console.log('#device:waiting'); return switchbot.wait(1000); }).then(() => { console.log('#device:disconnecting'); return device.disconnect(); }).then(() => { console.log('Done.'); res.end('OK!'); }).catch((error) => { console.error(error); res.end('error: ' + error); }); }; const server = http.createServer(requestListener); server.timeout = 5 * 1000; server.listen(5002); console.log('#http:started');
just call http://ip:5002/?id=mac and you're good to go. I just used my virtual device plug-in to have two virtual switches. It's already integrated into Alexa, WAF is high. Another thing removed from my long standing TODO list
@therealdb Thanks for the write up. I managed to setup it up with the Bot and is working. Now I just have to figure out how to write a .py and use mqtt to send the battery status over to Home Assistant.
The Switchbot Curtain is available. Do you think this will work as well? Atm, home assistant does not support the curtain.
-
I’m updating the battery to luup, so it should be doable. I think you may do the same for ha.
The curtain is supported, so this should be easily implemented.
@therealdb Thanks for the reply. Would you mind writing up commands for open and closing of curtain? I am not familiar with this code.
-
Someone over there has tried adding the curtain with the switchbot integration, but it does nothing. No response.