domoticz / domoticz

Open source Home Automation System
http://www.domoticz.com
GNU General Public License v3.0
3.48k stars 1.12k forks source link

Blyss modules 582866 operate only with an unit device composed with letter and a number #2228

Closed emoncuit closed 5 years ago

emoncuit commented 6 years ago

It's not possible to command a blyss module 582866 in Domoticz with a RFlink gateway. It's not possible in Domoticz to set an unit device like A1, B1, C1 (required for Blyss modules). Domoticz accepts only a value from 1 to 16 for the Blyss switch type. Could you fix this issue?

Regards,

Emmanuel

emoncuit commented 6 years ago

I found a workaround. In fact, the blyss module has to have a unit code with 2 characters. I have tried with "11" but domoticz sends "C" to the RFlink gateway. Domoticz has converted the value in hexadecimal. So I have set A1 as unit code to the module and 161 (A1 in decimal) in Domoticz. With this value, Domoticz sends well A1 and the switch works ! I have changed the code in updating the database with SQLiteManager.

I hope you can fix this issue in Domoticz.

lechunlx commented 6 years ago

What is you domoticz version? In my 3.8975 (git cloned from development branch) works fine with rflink.

emoncuit commented 6 years ago

I use the last stable version 3.8153. How can you install this version?

lechunlx commented 6 years ago

"Compiling from source code" https://github.com/domoticz/domoticz/blob/development/INSTALL.md

gizmocuz commented 6 years ago

Ehmmm no. better follow the updated wiki

https://www.domoticz.com/wiki/Raspberry_Pi_-_Build_Domoticz_from_source

(This works on most linux systems like Ubuntu/Debian)

BmdOnline commented 5 years ago

Hi, It's more subtle...

My Blyss 582866 module sends these commands :

20;01;Blyss;ID=3fae;SWITCH=G1;CMD=ON;
20;02;Blyss;ID=3fae;SWITCH=G1;CMD=OFF;

In fact, the unit ID is not hexadecimal ! Even with a manual database update, it's not possible to specify the unit code "G1".

BmdOnline commented 5 years ago

An Idea will be to store unit ID in another way : Instead of store directly ID as hex value (which is wrong sometimes), we can use hex code for each character. For example, when unit ID is "G1", we ca convert it to 0x4731 (0x47 means G, 0x31 means 1).

If I'm right, "unitcode" is stored as "int32_t". So, it can work without big changes.

Problem is for backward compatibility. Maybe, we can try this :

if unitID is really hex value, store it as usual (backward compatibility) else, store is with this new method

When we read it :

if unitID is below 0xFF, assume we have used old method else, we have used new method

Still here ? :wink: Do you think my reasoning is good ?

gizmocuz commented 5 years ago

Your correct, you can use it like this. I don't know if users have many blyss devices, if not, i think this change is mandatory and existing users will have to use the new switches that will appear after the patch

You might need to convert to hex, and then to integer again and use this as unit value

https://stackoverflow.com/questions/3381614/c-convert-string-to-hexadecimal-and-vice-versa

BmdOnline commented 5 years ago

I have tried an update in RFLinkBase.cpp. Now, I can interpret correctly unitID as described above.

But, I have another problem : Even with updated functions, Domoticz only store one byte in database, and read only one byte. Even if unitID have two.

If I'm right, problem is due to Domoticz database storage/reading functions (SQLHelper.cpp):

For example, function InsertDevice is using unsigned char instead of integer for unit declaration : InsertDevice(const int HardwareID, const char* ID, const unsigned char unit, const unsigned char devType, ...

I'm not experienced enough to modify this part Domoticz without side effects.

gizmocuz commented 5 years ago

@BmdOnline , you're right about that... the database has no limit, but that function does Lots have to be rebuild What kind of module is it ? (Blyss modules 582866), are you not better getting yourself a klik-aan-klik-uit or similar device ? (which works perfectly)

BmdOnline commented 5 years ago

For now, I have several 582866 modules, and tried to use them. If I can do something with them, that's fine. Otherwise I'll give up.

In the meantime, I have other devices (MySensors, Zigbee) without any problems. I don't know klik-aan-klik-uit.

gizmocuz commented 5 years ago

@BmdOnline , they probably have other compatible brand names like Chacon / CoCo Can't you set the ID inside the Blyss module so you do not need such a high ID ? But, A1, B1, C1 these are just numbers, in hex still a uint8_t like A1=161

BmdOnline commented 5 years ago

No, unfortunately, we can't change the unit ID.

gizmocuz commented 5 years ago

Okey, but... why not put the ID inside the DeviceID (where it could) and set the unit to 1 ?

So your device ID could be

3FAE4731 (3fae and G1)

gizmocuz commented 5 years ago

I think i did it... when you send "10;Blyss;003fae;G1;ON;" does it go on ?

Could you test beta 10407 ?

Could be you need to enable 'accept new devices' in the settings, you will get new switches You need to use these switches and remove the old ones

BmdOnline commented 5 years ago

I was thinking about something like that too. I'm going to test.

BmdOnline commented 5 years ago

I've tried it. It works. You may cleanup the code, but it's ok.

Comment CRFLinkBase : ParseLine("20;01;Blyss;ID=3fae;SWITCH=G1;CMD=ON;");

Comment SendSwitchInt : WriteToHardware((const char*)&gswitch, sizeof(gswitch));

And, maybe... avoid using "Blyss" string, in ParseLine : if ((switchType == "Blyss")&&(results[4].size()==9)) With : if ((GetGeneralRFLinkFromString(rfswitches, switchType) == sSwitchTypeBlyss)&&(results[4].size()==9))

Thanks.

BmdOnline commented 5 years ago

Well... I have another problem :disappointed:

For previous example, Domoticz is sending RFLink Sending: 10;Blyss;003fae;G1;OFF; And it's OK.

But for two other ones, I have RFLink Sending: 10;Blyss;ffffc65c;G1;OFF; and RFLink Sending: 10;Blyss;ffff82ac;G1;OFF;

Normally, it should be : RFLink Sending: 10;Blyss;0000c65c;G1;OFF; and RFLink Sending: 10;Blyss;000082ac;G1;OFF;

BmdOnline commented 5 years ago

Got it ! Use (pSwitch->id >> 16) & 0xFFFF instead of (pSwitch->id >> 16) when constructing command to send (in WriteToHardware)

Seems better.

gizmocuz commented 5 years ago

Sorry, yeah forgot to cleanup the code, just done so (beta 10409) Nothing wrong with using Blyss as string

So you are sure you are working with your new switches ? Can you post here what is received ? (the c65c and 82ac incomming)

gizmocuz commented 5 years ago

Okey, see what you mean, please try beta 10410

BmdOnline commented 5 years ago

Tried beta 10411, all seems good. Thanks again.

gizmocuz commented 5 years ago

Thanks for the feedback !