Page 1 of 1

Update devices rfy devices status

Posted: Tuesday 20 June 2017 0:00
by deennoo
Hi There.

I have a Somfy rts sunblind, all is ok with m'y rfxcom.

On Domoticz he got 3 buttons :
- open
- close
- stop

Using m'y RFLink i'm able to know if the Real remote is used and which ordre is send.

I want to use this ability to update the rfx devices. Not trigger but really update using commandarray['updatedevice'] command.

I found that value can be 0 or 1 but this value never update the device to "open".

Is There another secret value or do I need to use the Json api?

Re: Update devices rfy devices status

Posted: Wednesday 21 June 2017 9:23
by zicht
Hi

Have a look here, had simmilar questions before :
http://www.domoticz.com/forum/viewtopic ... 65#p137111

The only thing that does not work is receiving the original remote... so worked around that.
Hope it helps to understand better :)

Re: Update devices rfy devices status

Posted: Wednesday 21 June 2017 23:25
by deennoo
zicht wrote:Hi

Have a look here, had simmilar questions before :
http://www.domoticz.com/forum/viewtopic ... 65#p137111

The only thing that does not work is receiving the original remote... so worked around that.
Hope it helps to understand better :)
Rfx will never listen about Real remote, éven a Somfy tahoma didn't listen about rts remote.

Only RFLink or rfp1000 Can do this

Will check your code

Re: Update devices rfy devices status

Posted: Saturday 22 January 2022 17:15
by lec668
@Deeno

Hi,

Were you able to figure how to change the Somfy blinds status ? Here I'm trying to change it depending on a sensor.

I'm having the same trouble, RFY status change to 'stopped' whatever I put in the commandArray['UpdateDevice'] command, (tried On/Off Open/Closed...

if (devicechanged ['sensor_baie_bureau'] == "Open") then
print ("STORE BUREAU Open")
commandArray['UpdateDevice']='280|0|Off'
end

The command workds fine with another on/off light switch, but I've never beeen able to use it with a blind.

Regards !

Re: Update devices rfy devices status

Posted: Saturday 22 January 2022 19:22
by meal
Hello

I add the same functionality to setup.

You can use the following LUA function to update the RTS Blind based on the Status of the remote control.

function Visu_Blind_Status(Blind, Status)
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
iBlind=otherdevices_idx[Blind]
if Status=='On' then
value=18 -- Closed for Venetian EU Blind
elseif Status=='Off' then
value=17 -- Open for Venetian EU Blind
else
value=0 -- Stop
end
local url0 ="https://<<IP address>>/json.htm?type=command&param=udevice&idx=" .. iBlind.. "&nvalue=" ..value.. "&svalue=0&parsetrigger=false"
local url ='curl -s "' .. url0 .. '"'
local handle = io.popen(url)
local result = handle:read("*a")
handle:close()
output = json:decode(result)
if output==nil then
return nil
end
if output.status~="OK" then
return nil
end
return true
end

Example of implementation:

Blind1, Blind2, Blind3 are the name of the Somfy Blinds
Remote Control1, Remote Control2,Remote Contro3 are the name of the remote controls
Status is Open , Stopped or Closed


local RemoteControlBlinds = {
["Remote Control1"]="Blind1",
["Remote Control2"]="Blind2",
["Remote Control3"]="Blind3",
}


function timedifference(timestamp)
y, m, d, H, M, S = timestamp:match("(%d+)-(%d+)-(%d+) (%d+):(%d+):(%d+)")
difference = os.difftime(os.time(), os.time{year=y, month=m, day=d, hour=H, min=M, sec=S})
return difference
end

for RemoteControlBlind,Blind in pairs(RemoteControlBlinds) do
if (devicechanged[RemoteControlBlind]) then
s = otherdevices_lastupdate[RemoteControlBlind]
Status=otherdevices[RemoteControlBlind]
if timedifference(s) > 1 then -- to avoid successive state changes sent by the remote control
Visu_Blind_Status(Blind, Status)
end
end
end

BR

Re: Update devices rfy devices status

Posted: Thursday 03 February 2022 14:41
by lec668
Thanks, will have à look and convert it to "pure" lua / not JSON

Où avais-tu trouvé les valeurs 17 et 18 ?

Encore merci ! Thx

Re: Update devices rfy devices status

Posted: Thursday 03 February 2022 16:47
by meal
Hello,

I found the values 17 and 18 In the source codes.

I would be interested in the LUA version when you get it.

BR

Re: Update devices rfy devices status

Posted: Thursday 03 February 2022 17:13
by lec668
OK, I understand now, the "official" n & s values I took from the json documentation are not the ones I get

When manually testing with a http request I get
0 -> stopped
1 -> open
3 -> closed

So to reflect the real state of the blind, taken from my 'sensor_baie_bureau' here, it would change my script like this :


commandArray = {}

-- loop through all the changed devices
-- for deviceName,deviceValue in pairs(devicechanged) do
-- print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'");
-- end

if (devicechanged ['sensor_baie_bureau'] == "Closed") then
print("STORE BUREAU en cours de fermeture")
print( otherdevices['STORE BUREAU'] )
commandArray['UpdateDevice'] = '280|3|0'
--commandArray[#commandArray+1] = {['UpdateDevice'] = '280|3|0' }
elseif (devicechanged ['sensor_baie_bureau'] == "Open") then
print( otherdevices['STORE BUREAU'] )
print("STORE BUREAU completement ouvert")
commandArray['UpdateDevice'] = '280|1|0'
--commandArray[#commandArray+1] = {['UpdateDevice'] = '280|1|0' }
elseif (devicechanged ['BOUTON2'] == "Click") then
print("Click BOUTON2")
print( otherdevices['STORE BUREAU'] )
print("Click BOUTON2")
--just show the state of the blind in log when I press a pushbutton
end

return commandArray


Thanks for pointing me in the right direction ! A charge de revanche