anklimov / lighthub

Flexible, Arduino Mega/Due/ESP8266/ESP32/STM32 based SmartHome controller with DMX-512 in/out, 1-Wire, Modbus, MQTT interfaces. OpenHab/HomeAssistant/ioBroker compatible.
https://lazyhome.ru
Apache License 2.0
97 stars 23 forks source link

Template for custom device #21

Open livello opened 6 years ago

livello commented 6 years ago

I want to have "custom_device_type":{ "custom_device_name1":[param1,param2,param3], "custom_device_name2":[param1,param2,param3] } In config file (DHT11,DHT22, BMP280, Analog sensors, Encoders). It will be much better to have well designed template to make support of new devices. Associated build flag, config parsing, device initialization, send values using mqtt.

anklimov commented 6 years ago

There are two kind of devices now: sensors and actuators Sensors places to "input" Actuators placed to "items"

Item parameters:

#define I_TYPE 0 //Type of item
#define I_ARG  1 //Chanel-type depended argument or array of arguments (pin, address etc)
#define I_VAL  2 //Latest preset (int or array of presets)
#define I_CMD  3 //Latest CMD received
#define I_EXT  4 //Chanell-depended extension - array 

So this format is extendable for adding new types of actuator

input template:

"pin": { "T":"N", "emit":"MQTT emit topic", item:"out_item", "scmd": "ON,OFF,TOGGLE,INCREASE,DECREASE or value", "rcmd": "ON,OFF,TOGGLE,INCREASE,DECREASE or value", "rcmd":"repeat_command" }

T is bitmask from values:

#define IN_ACTIVE_HIGH   2      // High level = PUSHED/ CLOSED/ ON othervise :Low Level
#define IN_ANALOG         64     // Analog input (for further use)
#define IN_RE                   32     // Rotary Encoder (for further use)
#define IN_PUSH_ON        0      // PUSH - ON, Release - OFF (overrided by pcmd/rcmd) - DEFAULT
#define IN_PUSH_TOGGLE   1      // Every physicall push toggle logical switch  on/off (for further use)

Here some extension needed to threat "generic sensors" like DHT, BMP, NRF24, and even timers

livello commented 6 years ago

Lazyhome.ru LightHub controller 12a4cd9 _2018-06-09