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

Qubino Smart Plug 16A+ ZMNHYD1 does not obey Domoticz Switch Command #3646

Closed RicardP closed 4 years ago

RicardP commented 5 years ago

OZW 1.6.910.g0c01380b.dirty on Domoticz 4.11333 installed on Windows 10 platform.

I bought one ZMNHYD1 to find out if it "long term" performs better than couple of other brand products failing my expectations...

Inclusion went smoothly and things looked normal, however when sending Switch command results in message "error sending command... please check hardware" So, I tried to send the switch command in ozw control panel and it worked fine. Sometimes OZW crashed/restarted when sending the Switch command from Domoticz.

As I do not get the extended log to kick in, WIndows run as service (ps. Extended Log should be possible to activate inside Domoticz UI...), I have only the below error message in the log, fingers x-ed it gives a clue...

Error: OpenZWave: Exception. Type: 102, Msg: ValueID passed to SetValue is not a Int Value, File: OpenZWave::Manager::SetValue (Line 2748)

gizmocuz commented 5 years ago

Could it be you have received multiple switches for this node ? And maybe you need to use the other one ?

RicardP commented 5 years ago

Hello @gizmocuz I see which switch that toggles on off in Domoticz when I switch On Off from the Node push button, but when doing it from Domoticz I get the error message and Node does not switch... I just tried to delete all associated devices in device tab and then performed Refreshed Node Info, then I tried to first switch it from ozwcpl and... Bam! OZW crashed/restarted itself and after interview completed I tried again switch it from ozwcpl... it switches normally after re-interview!? ...but from Domoticz only error messages.

subtrEM commented 5 years ago

FWIW, same error message "OpenZWave: Exception. Type: 102, Msg: ValueID passed to SetValue is not a Int Value" encountered in with ZMNHYD1 switches. As stated in this forum message , i went back to OZW 1.4-3335-g74e05982-dirty; Domoticz 4.10717 [rwaaren: edit] Corrected forum link

RicardP commented 4 years ago

@gizmocuz do you have any idea why Domotics cannot send this Node switch command to OZW (ozw cpl works), is it a new type of Z-Wave CC that Domotics do not address the right way?

Cheers!

gizmocuz commented 4 years ago

@RicardP , could you post more log lines ? In the recent versions there should be more added like the file and line number

        _log.Log(LOG_ERROR, "OpenZWave: Exception. Type: %d, Msg: %s, File: %s (Line %d) %s:%d", 
            ex.GetType(), ex.GetMsg().c_str(), ex.GetFile().c_str(), ex.GetLine(),
            std::string(__MYFUNCTION__).substr(std::string(__MYFUNCTION__).find_last_of("/\\") + 1).c_str(), __LINE__);
RicardP commented 4 years ago

@gizmocuz is seems Domoticz log you ask for? I tried to activate logging but I don't get it switched on, I run Windows, as service, I tried setting the start up parameters/switches but seems not working for me. Has logging been confirmed working before in Windows, run as background service?

gizmocuz commented 4 years ago

If you switch, then go to setup->Log, there should be a error log

"OpenZWave: Exception. Type: 102, Msg: ValueID passed to SetValue is not a Int Value"

but then including the file/line

RicardP commented 4 years ago

@gizmocuz Like this? Error: OpenZWave: Exception. Type: 102, Msg: ValueID passed to SetValue is not a Int Value, File: OpenZWave::Manager::SetValue (Line 2748) COpenZWave::SwitchLight:1335

gizmocuz commented 4 years ago

@RicardP , yep, thats the one! Thanks

gizmocuz commented 4 years ago

@RicardP , could you post a screenshot of the control panel where you can toggle the switch on/off, I would like to see the current values In the openzwave hardware setup, from the dropdown, could you perform 'download configuration file' and attach this here as a zip?

RicardP commented 4 years ago

@gizmocuz I'm the one to say thanks :)

1

gizmocuz commented 4 years ago

@RicardP , thank you! Could you also attach here your configuration file ? Or part of the file that has the complete Node (80). You can download the configuration file from the dropdown menu (where you also choose to go to the control panel)

RicardP commented 4 years ago

...the config file as well:

ozwcache.zip

petergebruers commented 4 years ago

@gizmocuz this is a bit of a long shot, based on thorough reading of the source code. But I think it sounds plausible.

The ZMNHYD1 implements a more recent version of COMMAND_CLASS_SWITCH_BINARY than you are used to seeing. It has extra values...

From his cache file:

2

<Value type="bool" genre="user" instance="1" index="0" label="Switch" <Value type="bool" genre="system" instance="1" index="1" label="Target State" <Value type="byte" genre="system" instance="1" index="2" label="Transition Duration"

The switch code in Domoticz uses this to find the ValueID (it is used in other places as well):

bool COpenZWave::GetValueByCommandClass(const uint8_t nodeID, const uint8_t instanceID, const uint8_t commandClass, OpenZWave::ValueID& nValue)
{
    COpenZWave::NodeInfo* pNode = GetNodeInfo(m_controllerID, nodeID);
    if (!pNode)
        return false;

    for (const auto itt : pNode->Instances[instanceID][commandClass].Values)
    {
        uint8_t cmdClass = itt.GetCommandClassId();
        if (cmdClass == commandClass)
        {
            nValue = itt;
            return true;
        }
    }
    return false;
}

I am not sure in what order the values get pushed on that iterator, but it seems possible that the first match is not the switch Value (on/off)... Maybe it matches "Duration" and that ValueID needs an "int" which would explain the error "ValueID passed to SetValue is not a Int Value"

As I say, it is a long shot, but if I am right you'd want to GetValueByCommandClassIndex with ValueID_Index_SwitchBinary::Level

Sorry guys, due to personal circumstances I am unable to provide further assistance...

RicardP commented 4 years ago

@petergebruers thanks a lot for your inputs.

gizmocuz commented 4 years ago

@petergebruers , thanks, yes that was the reason for the configuration file. But then again, I only accept "OpenZWave::ValueID::ValueGenre_User" @RicardP , could you post one more screenshot ? From the devices tab where you highlight the switch (so i can see the deviceid/unit/type/...)

petergebruers commented 4 years ago

@gizmocuz,

But then again, I only accept "OpenZWave::ValueID::ValueGenre_User"

OK. I did notice you do vNodeValue.GetGenre() == OpenZWave::ValueID::ValueGenre_User in a few places, I wasn't sure if it filtered out everything in all cases.

Then it is the other way around (from what I've described above)... Domiticz probably is selecting the correct value ID, which is of type bool, but is calling Manager::SetValue manager with an integer. Is it (accidentally) treating this device like a MultiLevel Switch?

Just thinking out loud...

RicardP commented 4 years ago

@gizmocuz This is all devices generated from this plug...

2

petergebruers commented 4 years ago

@gizmocuz I think there are possibly 2 bugs...

(1) I would double check I only accept "OpenZWave::ValueID::ValueGenre_User" because I stepped through the debugger and I do think it is possible to match Value Index 2 which is a ValueGenre_System and is of type "byte"... This leads to the next problem.

(2) Because it is of type byte you'll then call m_pManager->SetValue(vID, 255); but 255 is an "int" so the compiler selects the int32 overload and then OZW throws an exception because it expects a byte. You'll want to cast it down, for example like this... line 1212

else if (vType == OpenZWave::ValueID::ValueType_Byte)
{
    if (svalue == 0) {
        //Off
        m_pManager->SetValue(vID, 0);
        pDevice->intvalue = 0;
    }
    else {
        //On
        m_pManager->SetValue(vID, (uint8) 255);
        pDevice->intvalue = 255;
    }
}

I could not spend more then about 1 hour on this so unfortunately you'll have to do with that terse explanation, sorry about that.

petergebruers commented 4 years ago

BTW fixing (2) imho will make the "exception" go away but I don't think it will solve the issue because of (1)

gizmocuz commented 4 years ago

@petergebruers , in both the AddValue as UpdateValue functions i check if it's a user genre and else discard it. I made a cast to uint8_t, let's see if that is working...

@RicardP , could you test beta 11364

If that does not work, do you live in the Netherlands ? If so, could you contact me on the forum ?

petergebruers commented 4 years ago

@petergebruers , in both the AddValue as UpdateValue functions i check if it's a user genre and else discard it.

Sorry for my limited available time, this is the last thing I can say. My debugger says... breakpoint on line 1221 in SwitchLight, that's this part:

//On m_pManager->SetValue(vID, (uint8) 255); pDevice->intvalue = 255;

So next step will not cause exception because of the cast... It will bomb without the cast. But that is not the point...

p vID; (OpenZWave::ValueID) $0 = (m_id = 46743569, m_id1 = 131072, m_homeId = 2576980377)

p vID.GetIndex() (uint16) $3 = 2

That's the "Transition Duration", not the Value...

p vID.GetGenre() (OpenZWave::ValueID::ValueGenre) $4 = ValueGenre_System

Now I really have to go. Good luck!

RicardP commented 4 years ago

@gizmocuz I am on Windows, checking betas says latest is 4.11363 but it looks like the build is not ready yet. I will check again soon!

Edit: Windows build is ready now, let you know the result soon...

RicardP commented 4 years ago

@gizmocuz sorry it did not work even the error message in Domoticz dose not show. It looks like it switches of, if on, but checking ozw cpl the state does not change.

Maybe non of the issue business but I wonder if this is new information generated to the log when ozw start up:

2019-10-14 17:16:01.108 Status: SendSwitchIfNotExists: Device '24.instance.1.index.0.commandClasses.38' (Level) with DeviceID '00001801' matches '24.instance.1.index.0.commandClasses.37' (Switch). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.123 Status: SendSwitchIfNotExists: Device '25.instance.1.index.0.commandClasses.38' (Level) with DeviceID '00001901' matches '25.instance.1.index.0.commandClasses.37' (Switch). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.248 Status: SendSwitchIfNotExists: Device '73.instance.1.index.256.commandClasses.113' (Previous Event Cleared) with DeviceID '00004900' matches '73.instance.1.index.0.commandClasses.48' (Sensor). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.248 Status: SendSwitchIfNotExists: Device '73.instance.1.index.1.commandClasses.156' (Smoke) with DeviceID '00004929' matches '73.instance.1.index.1.commandClasses.113' (Smoke Alarm). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.248 Status: SendSwitchIfNotExists: Device '73.instance.1.index.4.commandClasses.156' (Heat) with DeviceID '0000492C' matches '73.instance.1.index.4.commandClasses.113' (Heat). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.264 Status: SendSwitchIfNotExists: Device '74.instance.1.index.256.commandClasses.113' (Previous Event Cleared) with DeviceID '00004A00' matches '74.instance.1.index.0.commandClasses.48' (Sensor). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.264 Status: SendSwitchIfNotExists: Device '74.instance.1.index.1.commandClasses.156' (Smoke) with DeviceID '00004A29' matches '74.instance.1.index.1.commandClasses.113' (Smoke Alarm). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.264 Status: SendSwitchIfNotExists: Device '74.instance.1.index.4.commandClasses.156' (Heat) with DeviceID '00004A2C' matches '74.instance.1.index.4.commandClasses.113' (Heat). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.280 Status: SendSwitchIfNotExists: Device '75.instance.1.index.256.commandClasses.113' (Previous Event Cleared) with DeviceID '00004B00' matches '75.instance.1.index.0.commandClasses.48' (Sensor). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.280 Status: SendSwitchIfNotExists: Device '75.instance.1.index.1.commandClasses.156' (Smoke) with DeviceID '00004B29' matches '75.instance.1.index.1.commandClasses.113' (Smoke Alarm). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.280 Status: SendSwitchIfNotExists: Device '75.instance.1.index.4.commandClasses.156' (Heat) with DeviceID '00004B2C' matches '75.instance.1.index.4.commandClasses.113' (Heat). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.280 Status: SendSwitchIfNotExists: Device '76.instance.1.index.256.commandClasses.113' (Previous Event Cleared) with DeviceID '00004C00' matches '76.instance.1.index.0.commandClasses.48' (Sensor). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.295 Status: SendSwitchIfNotExists: Device '76.instance.1.index.1.commandClasses.156' (Smoke) with DeviceID '00004C29' matches '76.instance.1.index.1.commandClasses.113' (Smoke Alarm). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.295 Status: SendSwitchIfNotExists: Device '76.instance.1.index.4.commandClasses.156' (Heat) with DeviceID '00004C2C' matches '76.instance.1.index.4.commandClasses.113' (Heat). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.295 Status: SendSwitchIfNotExists: Device '77.instance.1.index.256.commandClasses.113' (Previous Event Cleared) with DeviceID '00004D00' matches '77.instance.1.index.0.commandClasses.48' (Sensor). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.295 Status: SendSwitchIfNotExists: Device '77.instance.1.index.1.commandClasses.156' (Smoke) with DeviceID '00004D29' matches '77.instance.1.index.1.commandClasses.113' (Smoke Alarm). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.311 Status: SendSwitchIfNotExists: Device '77.instance.1.index.4.commandClasses.156' (Heat) with DeviceID '00004D2C' matches '77.instance.1.index.4.commandClasses.113' (Heat). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.373 Status: SendSwitchIfNotExists: Device '97.instance.1.index.256.commandClasses.113' (Previous Event Cleared) with DeviceID '00006100' matches '97.instance.1.index.0.commandClasses.48' (Sensor). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.373 Status: SendSwitchIfNotExists: Device '97.instance.1.index.1.commandClasses.156' (Smoke) with DeviceID '00006129' matches '97.instance.1.index.1.commandClasses.113' (Smoke Alarm). Domoticz will use the Dimmer (and hide the Switch). 2019-10-14 17:16:01.373 Status: SendSwitchIfNotExists: Device '97.instance.1.index.4.commandClasses.156' (Heat) with DeviceID '0000612C' matches '97.instance.1.index.4.commandClasses.113' (Heat). Domoticz will use the Dimmer (and hide the Switch).

gizmocuz commented 4 years ago

@RicardP , are you Dutch ? If yes, could you send me a PM on the forum

RicardP commented 4 years ago

@gizmocuz No not Dutch but I have sent PM anyway :)

Edit: Not sure it worked, message is still in "Outbox" not "Sent messages".. ?

gizmocuz commented 4 years ago

@RicardP , could you try beta 11375 ?

RicardP commented 4 years ago

@gizmocuz thanks, I tried 11377 but unfortunately OZW crashes/restarts when toggle switch inside Domoticz. I also deleted the Node related Devices in Domoticz prior an Refresh Node Info, to avoid possible mismatches after code updates. But that did not change the outcome that OZW crash/restart if toggleing even the new created Domoticz Device-Switch.

gizmocuz commented 4 years ago

@RicardP , I develop on Windows so this should work. Let me test this again today

gizmocuz commented 4 years ago

@RicardP , it seems (and this seems a known issue that i have to investigate), that after the first time you include, and you switch from within domoticz, there is a crash When you restart, it working properly, could you check this ?

RicardP commented 4 years ago

@gizmocuz Voila! Yes now after OZW crash-restarted it switches correctly. I will start using this Node now and see if it behaves stable/normal.

Many thanks!! :)

petergebruers commented 4 years ago

I am glad I could point you in the right direction. And on behalf of the OpenZWave Team (so to speak), sorry about the "crash" after first use, it is a known issue indeed, see https://github.com/OpenZWave/open-zwave/issues/1981 and https://github.com/domoticz/domoticz/issues/3530

petergebruers commented 4 years ago

BTW @gizmocuz I am working to improve the message you get when something's wrong about your ValueID. Right now all you get is:

Msg: ValueID passed to SetValue is not a Int Value

This is in test and it still is not final but to give you an idea, that message could have this extra bit (random sample, not related to this issue):

HomeID: 0x00000001, ValueID: 0x0006000002c10057 (NodeID 2, Genre system, CC 0x04, Instance 5, Index 6, Type string)

I think that would have uncovered the fact that Domoticz was matching a "ValueGenre_System"...

gizmocuz commented 4 years ago

@petergebruers , only type user where allowed in AddValue/UpdateValue, but all values where also stored in the system. Which is good and could be used later to enrich it. It would be great if we could have the crash resolved , or checking the whole library against 'nullptr' so we could bring out a new stable release. After this, I will redesign the DeviceID generation so we can match internally the index/instances