Hello,
As I explained some days ago, I started to implement a new hardware plugin for an old home automation system which I can communicate through USB/Serial/RS485.
After reading, coding, debugging, I can say that I can understand a bit the Domoticz architecture but I need your help.
At this moment I achieved:
In Domoticz FrontEnd, after following this guide (https://www.domoticz.com/wiki/Developin ... are_plugin) I can see the new hardware in the setup part, I can add it and configure to use the COM port, where I have a USBtoRS485 converter, and I can receive the data from the hardware. I can interpret the messages coming from the hard, in that case I can see the "INPUTS" and the "OUTPUTS" status. And I can test that I can write successfully a message to the hard.
But in the other hand, if I try to add a light/Switch manually in the frontend, I can see the new Hardware device in the first combo, and I can select Switch Type, Type, and depending on the previous options, different combinations of ID, House Code, Unit Code...
My question is, how can "translate" the message from the "Test" button so I can really switch on/off a light that is an "OUPUT" of my system.
In the other hand I know that I need to use the "sDecodeRXMessage" function to decode the info from my hardware and send to Domoticz. But how can I map this info with the corresponding switches added manually in the frontend?
My home automation system, basically have a "controller", then it can have as a maximum 8 modules of 16 inputs each, and a maximum of 16 modules of 8 ouputs each (128 outputs and 128 inputs max). So, in the frontend part, when adding manually the light/switch, would it be perfect to have a new Type of "Switch Type - On/Off", where I could select the module (from 1 to 16) [Module combo], and also select the Output (from 1 to 8) [Output combo]. This way I'll have a total maximum of 128 ouputs I need.
Then, What Is needed to modify in the frontend part so I can see this new Type with 2 combos (module/ouput), and what I need to modify in the backendpart, where I've implemented the new hardware plugin, where I have the Class, StartHardware, StopHardware, Do_Work, OpenSerialDevice, readCallback (where I handle the data coming from the home automation system, and I write to it if necesssary).
I see in other plugins this piece of code
//Webserver helpers
namespace http {
namespace server {
void CWebServer::
is this the key to receive the info from the frontend?
And how I need to format the info in "sDecodeRXMessage" so the switch in the frontend can be updated accordingly ?
Thanks a lot!
How to update Domoticz switches from new hardware and vice versa
Moderators: leecollings, remb0
-
- Posts: 3
- Joined: Wednesday 09 November 2016 19:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to update Domoticz switches from new hardware and vice versa
Hello again,
Well, after more debugging, I understood a bit how the status from the frontend is sent to the backend.
For my "alfa" development, I'll use the default combinations of Switch Type (On/Off), Type (X10), House Code (A-P) and Unit Code (1-16), until I know how to add a new custom hardware in HardwareController.js and LightsController.js.
I modified the SwitchLightInt function in mainworker.cpp with the code that you can see between //START and //END. With this I can use the "Test" functionality of the "Add Manual Light/Switch Device". I can receive the "ON" command so I can switch on the light selected by "House Code" and "Unit Code". In my case "House Code" is one of the 16 ouput modules I have, and "Unit Code" is the output/light. (each module only have 8 outputs, this is why I'm checking lcmd.LIGHTING1.unitcode < 9).
So my question is, "Is that approach correct?" I'm "breaking" the architecture of Domoticz with those changes? Or I can continue this way and once I have the plugin completed I will able to e.g. comunicate my hardware with other systems (e.g. MQTT) through Domoticz?
Thanks
Well, after more debugging, I understood a bit how the status from the frontend is sent to the backend.
For my "alfa" development, I'll use the default combinations of Switch Type (On/Off), Type (X10), House Code (A-P) and Unit Code (1-16), until I know how to add a new custom hardware in HardwareController.js and LightsController.js.
I modified the SwitchLightInt function in mainworker.cpp with the code that you can see between //START and //END. With this I can use the "Test" functionality of the "Add Manual Light/Switch Device". I can receive the "ON" command so I can switch on the light selected by "House Code" and "Unit Code". In my case "House Code" is one of the 16 ouput modules I have, and "Unit Code" is the output/light. (each module only have 8 outputs, this is why I'm checking lcmd.LIGHTING1.unitcode < 9).
Code: Select all
if (!GetLightCommand(dType, dSubType, switchtype, switchcmd, lcmd.LIGHTING1.cmnd, options))
return false;
//START Special Teach-In for IHCSerial
if ((pHardware->HwdType == HTYPE_IHCSerial))
{
if (lcmd.LIGHTING1.unitcode < 9) {
CIHCSerial::ihcCmd_t OnOff;
if (lcmd.LIGHTING1.cmnd == light1_sOff) {
OnOff = CIHCSerial::ihcCmd_t::OFF;
}
else {
OnOff = CIHCSerial::ihcCmd_t::ON;
}
int ihcport = (lcmd.LIGHTING1.housecode - 65) * 10 + lcmd.LIGHTING1.unitcode;
CIHCSerial *pIHC = reinterpret_cast<CIHCSerial*>(pHardware);
pIHC->SendCommand(OnOff, ihcport);
if (!IsTesting) {
//send to internal for now (later we use the ACK)
PushAndWaitRxMessage(m_hardwaredevices[hindex], (const unsigned char *)&lcmd, NULL, -1);
}
return true;
}
else {
return false;
}
}
//END Special Teach-In for IHCSerial
if (switchtype==STYPE_Doorbell)
Thanks
Who is online
Users browsing this forum: No registered users and 1 guest