dzVents Error Expression Expected >> Operator  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
rwblinn
Posts: 72
Joined: Wednesday 10 June 2015 21:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 4
Location: Hamburg (Germany)/Middelburg (NL)
Contact:

dzVents Error Expression Expected >> Operator

Post by rwblinn »

Domoticz 2022.1; Raspberry Pi 3B+, Raspberry Pi OS,

Got an error message "Expression expected near >" when declaring the >> operator:

Code: Select all

t[i+1] = (value >> (i * 16)) & 0xFFFF
in the code below. Also tried to use the << operator.

What is the correct way to use the << and >> operators in dzVents.

Code: Select all

...
execute = function(domoticz, device)
	domoticz.log(("%s: %s"):format(device.name, device.sValue))
	local value = tonumber(device.sValue)
        local t = {}
        for i = 0, 3 do
	    'ERROR
            t[i+1] = (value >> (i * 16)) & 0xFFFF
        end
        domoticz.log(t)
end
...
User avatar
boum
Posts: 136
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: dzVents Error Expression Expected >> Operator  [Solved]

Post by boum »

Shift operators do not exist in Lua. You'll have to convert to math:

Code: Select all

t[i+1] = (value // (2 ^ (i * 16))) % (2 ^ 16)
rwblinn
Posts: 72
Joined: Wednesday 10 June 2015 21:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 4
Location: Hamburg (Germany)/Middelburg (NL)
Contact:

Re: dzVents Error Expression Expected >> Operator

Post by rwblinn »

Thats it. Thanks for help.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest