OpenZWave / node-openzwave-shared

OpenZWave addon for Node.js (all versions) including management and security functions
Other
199 stars 113 forks source link

Reset a meter (command class METER) with pressButton fails #337

Closed gxapplications closed 4 years ago

gxapplications commented 5 years ago

Hello,

I have a Fibaro FGWPE/F Wall Plug Gen5, and annother Fibaro product that both supports METER command class. Since I migrate to the OpenZwave 1.6 (from 1.4) I noticed the Reset feature of METER Command Class index changed from 33 to 257. The problem is the new index is 257 in fact. So when I call zwave.pressButton(4, 50, 1, 257), I got this error : TypeError: OpenZWave valueId not found: 4-50-1-1 I'm not pressing the button at index 1, but at index 257... It should be out of 0-256 bounds maybe... I looked in open-zwave lib, and confirmed that the Reset feature is well affected at index 257: https://github.com/OpenZWave/open-zwave/blob/4478eea26b0e1a29184df0515a8034757258ff88/cpp/src/ValueIDIndexesDefines.h#L86

In ozwcache file, I have this, confirming the feature Reset at unreachable index:

<Node id="4" name="Plug test" location="Escaliers" basic="4" generic="16" specific="1" roletype="5" devicetype="1792" nodetype="0" type="Binary Power Switch" listening="true" frequentListening="false" beaming="true" routing="true" max_baud_rate="100000" version="4" configrevision="5" query_stage="Complete">
        <Manufacturer id="10f" name="FIBARO System">
            <Product type="602" id="1001" name="FGWPE/F Wall Plug Gen5">
                <MetaData>
                    ......
                </MetaData>
            </Product>
        </Manufacturer>
        <CommandClasses>
            <CommandClass id="50" name="COMMAND_CLASS_METER">
                <Compatibility />
                <State>
                    <CCVersion>2</CCVersion>
                    <InNif>true</InNif>
                    <StaticRequests>2</StaticRequests>
                </State>
                <Instance index="1" />
                <Value type="decimal" genre="user" instance="1" index="0" label="Electric - kWh" units="kWh" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="0.42">
                    <Help></Help>
                </Value>
                <Value type="decimal" genre="user" instance="1" index="2" label="Electric - W" units="W" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="0.0">
                    <Help></Help>
                </Value>
                <Value type="bool" genre="user" instance="1" index="256" label="Exporting" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="False">
                    <Help></Help>
                </Value>
                <Value type="button" genre="system" instance="1" index="257" label="Reset" units="" read_only="false" write_only="true" verify_changes="false" poll_intensity="0" min="0" max="0">
                    <Help></Help>
                </Value>
            </CommandClass>
....

How to reset a METER if we cannot use pressButton(x, y, z, 257) ???

xGouley commented 5 years ago

Someone back from holidays ? :)

gxapplications commented 5 years ago

Nobody on this project?

gxapplications commented 5 years ago

Apparently, not solvable on the OZW lib side (https://github.com/OpenZWave/open-zwave/issues/1945). Any fix or solution ?

robertsLando commented 5 years ago

@gxapplications for buttons I use the api setValue(valueId, value) by use true as value and it works

Fishwaldo commented 5 years ago

Button is not the issue. It’s that the index variable was increased from a byte to a short. If your inputting 257 but OZW is seeing 1, then then conversion didn’t happen in the wrapper correctly.

robertsLando commented 5 years ago

@Fishwaldo So how to fix this?

Fishwaldo commented 5 years ago

Make sure index values in the wrapper can handle short sized integers.

robertsLando commented 5 years ago

@Fishwaldo https://github.com/OpenZWave/node-openzwave-shared/blob/master/src/utils.hpp#L49 should be already handled

Fishwaldo commented 5 years ago

Based on the logs provided, index 257 turned into index 1 which is a overflow!

gxapplications commented 4 years ago

Actually testing 1.5.10 against 1.5.0, the bug seems to be fixed between these 2 versions. Thank you !