This project connects dwelo (a smarthome platform for apartments) to homeassistant. This uses direct access to the dwelo hub and takes miliseconds to execute commands (instead of multiple seconds if you use the online at api.dwelo.com) Using this shim with hass/homekit with this shim is significantly faster than using the dwelo app or webpage.
I didn't open source this out of fear that dwelo would catch on and remove/change stuff and break me. I now don't live in the apartment complex, so I'm open sourcing it now in hopes that people can benefit from it.
It also appears that newer Dwelo hardware may not be based off a raspbery pi anymore and so this is likely not very applicable anymore anyway. More info here #1
The point of this project was to
- Get the smarthome devices in dwelo connected to homekit
- Leave all dwelo things as it, it (dwelo) still needs to work 100% as it originally did
- Don't talk to the "Public" dwelo API
- I tried this first and it was extremely slow
- All calls are made locally from HASS, directly to the dwelo-hub and don't require internet access (a network is required, but no internet)
For that reason (#2), instead of hijacking the ZWAVE controller directly (which is totally possible), I built a shim program that reads data output by dwelo logs and syncs it up to the homeassistant switch. If setting from homeassistant, hass will call the shim program, which will talk to the private dwelo api and trigger that change. I only had switches hooked up. A lock was hooked up at one point in time, but was slow reporting the info/receiving commands and I didn't ever use it, so I didn't care about writing code around that pitfall.
The program has run nearly a year (with PM2) without needing intervention by me. It did need intervention after a power outage.
- Get physical access to the dwelo-hub
- In my case, it was a physical raspberry pi connected to the router
- Log into your router and see if you can find an IP addess for it
- You can check if you have the right IP by going to :9001 and see if you find the dwelo status screen
- You can also try http://dwelo-hub.local:9001 and see if you can see it there.
- Create yourself a user
- Install homeassistant (If you have an existing homeassistant, you should be able to edit the config/config.js file with that info)
- If trying to use a separate homeassistant server, you may also need to make sure that the
dwelo-shim
port is open to the world
- If trying to use a separate homeassistant server, you may also need to make sure that the
- Pull this project
- run
node getHassConfigs
- It will auto discover your dwelo devices and generate a hass config
- Probably only works for switches, locks might work
- Put those configs into home assistants and reboot it
- Run this project using
pm2 start
ornpm run start
- You should now have home assistant switches that work!
I don't remember 100%, but it went something like this
- remove SD card, put in another (linux) computer
- on
boot
in cmdline.txt appendsystemd.unit=rescue.target
- on the main partition, edit
/lib/systemd/system/rescue.service
and add --force after sulogin to the ExecStart line ->ExecStart=-/bin/sh -c "/sbin/sulogin --force; ...
Theres quite a bit of python files you can find to reverse engineer the API. The stuff that runs on port 9001 is open to the public network and exposes some info
- Base: http://192.168.11.27:9001/api/
- Status: http://192.168.11.27:9001/api/controller/status
- Get Devices: http://192.168.11.27:9001/api/devices/
- Lock/unlock local: localhost:5000/device/10/command/door/lock/close/
- Edit name of device: http://192.168.11.27:9001/devices/10/update/
The stuff that runs on port 5000 actually controls the devices and can lock/unlock, turn on/off lights, etc.
Useful dwelo files
/home/dwelo/hub/bin/activate
/home/dwelo/zipgateway/bin/activate
- has the serial port that dwelo uses to talk to the z-wave devices
- also has the db user/password that has some interesting info in it
/var/cache/salt/minion/files/base/gateway/production/files/etc/supervisor/conf.d/
- a few files in this dir
zipgateway.conf
has the z wave encryption key on it (for secure devices like locks)
- db tables
Tables_in_dweloHub |
---|
Abilities |
AccessCodeSlotStatus |
AccessCodes |
Actions |
AddressMaps |
Addresses |
AlertViews |
Alerts |
CommandQueue |
Communities |
Devices |
GatewaySettings |
GeoFences |
Occupants |
Permissions |
Permissions_history |
PubNubChannelGroups |
PubNubChannels |
RoleAbilities |
Roles |
Schedules |
SensorReadings |
UserCommunityRoles |
Users |
alembic_version |