How to connect my device to the local network and how to add it to be managed by the Casanet server?
Good question... depend on device protocol.
Connect the device to a local network by official app.
Then scan the local network by the Casanet server.
Connect the device to a local network by official app.
Then scan the local network by the Casanet server.
Connect the device to a local network by official app. then you have to enable the LAN Control see instruction with pictures.
Then scan the local network by the Casanet server.
Connect the device to a local network by official app. then you have to get the device token to see Obtain Mi Home device token.
Then scan the local network by the Casanet server.
Tasmota is a great open-source firmware for ESP8266 based boards. see the project here.
After flashing and configure the device to connect to the local home WIFI (there are many tutorials, for me thats worked).
Then scan the local network by the Casanet server.
This module using the HTTP API of Tasmota. and assuming that there is no username/password required.
MQTT is a great open-source publish-subscribe system for IoT devices.
For integration guide see MQTT module
Connect the device to a local network by official app. Note that a lot of Chinese devices supported Tuya API, see Tuyapi project.
Then you need to get the device id and key before it can reach by the Casanet server. to get the id and key see Linking a Tuya Device.
After you get the id and key (called token in Casanet) then scan it insert the id and key/token and add it to the Casanet server.
Note that the Tuya device key changed each time that setting a new local network SSID. and then the device's status became read-only until the Casanet update with the correct new key.
Note that the Tuya device can communicate by only one TCP connection, so if the Tuya app is open the Casanet server could not communicate with the device.
To allow a server to communicate with many models and manufacturers each brand needs to write own module that inherits from brandModuleBase.ts.
So to create a new brand/communication protocol module:
- Fork the project.
- Create a new folder with the brand name in
backend/src/modules
. - Create in the new folder new ts file, name format
xxxxHandler.ts
. - Write a class that inherits from brandModuleBase.ts.
- Write the module communication code (getStatus / setStatus etc.).
- Add import to the new module in modulesManager.ts file (line 9).
- Create an instance of the module in modulesManager.ts file (line 71).
- Build by
npm run build
. - Open PR ;).
You can see a demo of brandModuleBase.ts API and used by watch the mock module.