Fibaro Roller Shutter percentage issue (FGR-223)
Moderator: leecollings
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Fibaro Roller Shutter percentage issue (FGR-223)
So I went ahead a bought my myself a set of Fibaro Roller Shutters v3 and installed them. When creating the devices as simple up/down they work as expected. When I try to use the percentage, which could be quite a handy feature, they don't report back the correct value.
For example, when I choose to go down 50% and then proceed to 75% it will fall back to the value of 50% in the GUI. When I enable polling for the device it works better, but I don't think this is a correct solution.
I have read about others making a script which updates the value of the device when it's being powered. So as long as the motor is pulling electricity it will keep updating. I have not managed to get this in Domoticz however, but this could be a workaround I can live with.
Searching Google gave my some results, but not a working solution yet.
For example, when I choose to go down 50% and then proceed to 75% it will fall back to the value of 50% in the GUI. When I enable polling for the device it works better, but I don't think this is a correct solution.
I have read about others making a script which updates the value of the device when it's being powered. So as long as the motor is pulling electricity it will keep updating. I have not managed to get this in Domoticz however, but this could be a workaround I can live with.
Searching Google gave my some results, but not a working solution yet.
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Hmm, the following topic just popped up. Seems there are still issues. However, maybe someone can come up with a working 'refresh' script?
https://www.domoticz.com/forum/viewtopi ... 24&t=26218
https://www.domoticz.com/forum/viewtopi ... 24&t=26218
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Hi,
I've managed to address this issue and now I have it working rock solid
IMHO the solution presented in the aforementioned topic does not work as expected for two reasons:
a) Domoticz does not correctly send the 'Open' command to FGR-223. It sends value 255, which means set last position, not 'Open'. For 'Open', FGR-223 expects value 99 (that is actually quite clearly described in Z-Wave SWITCH_MULTILEVEL command specification). So if You only open/close a blind, that will work, but only due to the fact, that previous position would be 0 (closed) or 99 (opened). But if You try to position the blind i.e on 50% level and then try to open it fully, the blind wont position correctly
b) From my experience device.level value does not provide currently set level upon device script execution.
So first of all, the erratic domoticz behavior for the Open signal has to be fixed. I've managed to do this by altering slightly the code (OpenZWave.cpp).
Than I've made a solution, that parses domoticz.log to get the required level to be set and after a few seconds (I actually count the required time for the blind to stop ) it sets nValue and sValue for the blind. That corrects the final blind position in the GUI without actually sending anything again to FGR-223.
If someone is interested in the details, let me know
I've managed to address this issue and now I have it working rock solid
IMHO the solution presented in the aforementioned topic does not work as expected for two reasons:
a) Domoticz does not correctly send the 'Open' command to FGR-223. It sends value 255, which means set last position, not 'Open'. For 'Open', FGR-223 expects value 99 (that is actually quite clearly described in Z-Wave SWITCH_MULTILEVEL command specification). So if You only open/close a blind, that will work, but only due to the fact, that previous position would be 0 (closed) or 99 (opened). But if You try to position the blind i.e on 50% level and then try to open it fully, the blind wont position correctly
b) From my experience device.level value does not provide currently set level upon device script execution.
So first of all, the erratic domoticz behavior for the Open signal has to be fixed. I've managed to do this by altering slightly the code (OpenZWave.cpp).
Than I've made a solution, that parses domoticz.log to get the required level to be set and after a few seconds (I actually count the required time for the blind to stop ) it sets nValue and sValue for the blind. That corrects the final blind position in the GUI without actually sending anything again to FGR-223.
If someone is interested in the details, let me know
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
@Michalux, yes, I'm interested in your solution.
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
OK, lets try
First of all You have to prepare the environment to build domoticz from source, since a little change is required in its code. Use this manual: https://www.domoticz.com/wiki/Build_Dom ... rom_source
Then, follow the steps below:
1. Alter the following section in dev-domoticz/hardware/OpenZWave.cpp (this will force domoticz to send value 99 instead of 255 for the "Open" command:
2. Save changes and build domoticz from source.
3. Redirect domoticz logs to a separate file. Do it using rsyslog configuration. Prepare /etc/rsyslog.d/domoticz.conf:
Restart rsyslog.
4. Stop domoticz process, copy built domoticz executable to Your running domoticz folder (first make backup of the original one ) and start domoticz again.
5. Prepare shell script (i.e in scripts folder) that will constantly parse domoticz.log (lets call it FibaroLevel.sh). Script should tail -F domoticz.log and look for phrase: 'Domoticz has send a Switch command!, Level:'. In this line You will always find both NodeID and shutter level to be set. You have to get both values from this line (I use string substitution for this). Then You have to map NodeID to Domoticz DeviceName pointing to Your shutter switch device (You'll need it in a moment). NodeID You will find in ZWave controller configuration menu and DeviceName in Devices menu. Having both values You'll be ready to run script from the following point (SetValues.sh) with both values as variables. Important - SetValues.sh has to be forked/run in background ! (./SetValues DEVICE LEVEL &). Alternatively You can run both sleep and curl commands from SetValue.sh right from FibaroLevel.sh - for instance like this: (sleep 30; curl ......)&
Script can look like this:
6. Prepare another shell script (i.e. SetValues.sh), that will:
a) wait a few seconds
b) run domoticz dzVents/Custom Events script to set the required shutter level
The script can look like this:
where: $DEVICE keeps DeviceName and $LEVEL of course the required level
7. Now the final part: prepare dzVents->Custom events script, that will look like this:
8. Run the main script forever: ./FibaroLevel.sh &
And You're done Simple - isn't it ?
First of all You have to prepare the environment to build domoticz from source, since a little change is required in its code. Use this manual: https://www.domoticz.com/wiki/Build_Dom ... rom_source
Then, follow the steps below:
1. Alter the following section in dev-domoticz/hardware/OpenZWave.cpp (this will force domoticz to send value 99 instead of 255 for the "Open" command:
Code: Select all
//dimmable/color light device
if ((svalue > 99) && (svalue != 255))
svalue = 99;
if (GetValueByCommandClassIndex(pDevice->nodeID, (uint8_t)instanceID, COMMAND_CLASS_SWITCH_MULTILEVEL, ValueID_Index_SwitchMultiLevel::Level, vID) == true)
{
std::string vLabel = m_pManager->GetValueLabel(vID);
// Special case for Fibaro FGR-223 (Roller Shutter 3)
if ( (pDevice->Manufacturer_id == 0x010F) && (pDevice->Product_id == 0x1000) && (pDevice->Product_type == 0x0303) ) {
if ( svalue == 255 ) {
pDevice->intvalue = 255;
svalue = 99;
}
}
else {
pDevice->intvalue = svalue;
}
3. Redirect domoticz logs to a separate file. Do it using rsyslog configuration. Prepare /etc/rsyslog.d/domoticz.conf:
Code: Select all
if $programname == 'domoticz' then /var/log/domoticz.log
& stop
4. Stop domoticz process, copy built domoticz executable to Your running domoticz folder (first make backup of the original one ) and start domoticz again.
5. Prepare shell script (i.e in scripts folder) that will constantly parse domoticz.log (lets call it FibaroLevel.sh). Script should tail -F domoticz.log and look for phrase: 'Domoticz has send a Switch command!, Level:'. In this line You will always find both NodeID and shutter level to be set. You have to get both values from this line (I use string substitution for this). Then You have to map NodeID to Domoticz DeviceName pointing to Your shutter switch device (You'll need it in a moment). NodeID You will find in ZWave controller configuration menu and DeviceName in Devices menu. Having both values You'll be ready to run script from the following point (SetValues.sh) with both values as variables. Important - SetValues.sh has to be forked/run in background ! (./SetValues DEVICE LEVEL &). Alternatively You can run both sleep and curl commands from SetValue.sh right from FibaroLevel.sh - for instance like this: (sleep 30; curl ......)&
Script can look like this:
Code: Select all
#!/bin/bash
DEVICE=""
LEVEL=""
tail -F /var/log/domoticz.log | while read LINE; do #Point to Your actual domoticz.log
if [[ $LINE == *'Domoticz has send a Switch command!, Level:'* ]]; then
TMP=${LINE#*ID: }
NODEID=${TMP% (*}
TMP=${LINE#*Level: }
LEVEL=${TMP%,*}
if [[ $LEVEL == "255" ]]; then
LEVEL="99"
fi
case $NODEID in #Use Your nodeids and devicenames !
2) DEVICE='Shutter1';;
3) DEVICE='Shutter2';;
4) DEVICE='Shutter3';;
esac
/opt/domoticz/scripts/SetValues.sh "${DEVICE}" ${LEVEL} &
DEVICE=""
LEVEL=""
fi
done
a) wait a few seconds
b) run domoticz dzVents/Custom Events script to set the required shutter level
The script can look like this:
Code: Select all
#!/bin/bash
DEVICE=$1
LEVEL=$2
sleep 30 #wait 30s to set level value in domoticz
curl -ks -d "type=command¶m=customevent&event=FibaroLevelUpdate&data=[{\"DEVICE\":\"${DEVICE}\",\"LEVEL\":\"${LEVEL}\"}]" -X POST https://127.0.0.1/json.htm
7. Now the final part: prepare dzVents->Custom events script, that will look like this:
Code: Select all
return {
on = {
customEvents = { 'FibaroLevelUpdate' }
},
logging = {
level = domoticz.LOG_DEBUG --this is optional in order to get more info
},
data = { },
execute = function(domoticz, triggeredItem)
if ( triggeredItem.data[1].LEVEL == '99' ) then --Shutter opened
nValue=1
sValue=100
elseif ( triggeredItem.data[1].LEVEL == '0' ) then --Shutter closed
nValue=0
sValue=0
else --Shutter leveled
nValue=2
sValue=triggeredItem.data[1].LEVEL
end
domoticz.log('***** Setting nValue='..nValue..', sValue='..sValue.." for: "..triggeredItem.data[1].DEVICE, domoticz.LOG_INFO)
domoticz.devices(triggeredItem.data[1].DEVICE).setValues(nValue, sValue) --this one actually sets the correct values without moving the shutter again.
end
}
And You're done Simple - isn't it ?
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
It sure look simple indeed. Since my Domoticz install has crashed, I can rebuilt now with this option already implemented
Perhaps it would be nice to add this to Github for a future update?
Perhaps it would be nice to add this to Github for a future update?
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
This is only some kind of workaround ... so I doubt Domoticz developers would agree to implement it permanently
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
While that may be true (or expected), perhaps the developers will see another solution based on your implementation
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Actually, I've just figured out a totally different, much simpler and I guess better way to refresh blind's level in GUI
It does not require any shell script for it to work
Reading ZWave Domoticz's source code, I've stumbled upon a function, that refreshes ZWave node parameter values (i.e. level)
It appeared, that refreshing those values, also refreshes status in GUI.
So to refresh any ZWave device parameter's info, we just need to invoke this function.
For this I've prepared a simple dzVents Device script, that looks like this:
Script fires on device change (BLIND1-3). It requires a mapping from device.name to ZWave NodeID (this can be found in ZWave controller configuration menu). Having NodeID it opens the above URL sending parameters listed in postData. URL is actually being opened after 30 seconds, just to wait for the blind to reach it's final position.
And that's it
It does not require any shell script for it to work
Reading ZWave Domoticz's source code, I've stumbled upon a function, that refreshes ZWave node parameter values (i.e. level)
It appeared, that refreshing those values, also refreshes status in GUI.
So to refresh any ZWave device parameter's info, we just need to invoke this function.
For this I've prepared a simple dzVents Device script, that looks like this:
Code: Select all
return {
on = {
devices = {
'BLIND1',
'BLIND2',
'BLIND3',
}
},
execute = function(domoticz, device)
if device.name == 'BLIND1' then NODEID=2
elseif device.name == 'BLIND2' then NODEID=3
elseif device.name == 'BLIND3' then NODEID=4
end
domoticz.openURL({
url = 'http://127.0.0.1:8080/ozwcp/refreshpost.html',
method = 'POST',
postData = { 'fun=racp&node='..NODEID }
}).afterSec(30)
end
}
And that's it
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Ha, I've just finished my built
Will revert to the original version of Domoticz. Thanks for the update!
Will revert to the original version of Domoticz. Thanks for the update!
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Don't revert. Above script is only to refresh level values in GUI (it replaces whole bash + dzVents scripts solution). Domoticz code change is to correct open value (99 instead of 255), that Domoticz sends to Fibaro controllers. Without it, You'll probably get erratic shutter behavior in some circumstances. Try for instance close the shutter, than level it to 50% and next open it fully using open switcher button - probably it won' t open. Instead it will fully close (since 255 means: go to the last position).
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Maybe a dumb question but what is the domoticz executable? I assume you don't mean domoticz.sh but the file domoticz?
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
domoticz.sh is a script, not executable. I mean file: domoticz (one having execute rights).
-
- Posts: 29
- Joined: Monday 28 November 2016 18:38
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
In that case my thoughts were correct
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Very interesting. It seems that afterSec is not working for me and the command is executed inmediately. Doy you know the reason? Thanks a lot.Michalux wrote: ↑Sunday 05 April 2020 22:49 Actually, I've just figured out a totally different, much simpler and I guess better way to refresh blind's level in GUI
It does not require any shell script for it to work
Reading ZWave Domoticz's source code, I've stumbled upon a function, that refreshes ZWave node parameter values (i.e. level)
It appeared, that refreshing those values, also refreshes status in GUI.
So to refresh any ZWave device parameter's info, we just need to invoke this function.
For this I've prepared a simple dzVents Device script, that looks like this:Script fires on device change (BLIND1-3). It requires a mapping from device.name to ZWave NodeID (this can be found in ZWave controller configuration menu). Having NodeID it opens the above URL sending parameters listed in postData. URL is actually being opened after 30 seconds, just to wait for the blind to reach it's final position.Code: Select all
return { on = { devices = { 'BLIND1', 'BLIND2', 'BLIND3', } }, execute = function(domoticz, device) if device.name == 'BLIND1' then NODEID=2 elseif device.name == 'BLIND2' then NODEID=3 elseif device.name == 'BLIND3' then NODEID=4 end domoticz.openURL({ url = 'http://127.0.0.1:8080/ozwcp/refreshpost.html', method = 'POST', postData = { 'fun=racp&node='..NODEID } }).afterSec(30) end }
And that's it
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
First I would check if Your domoticz responds to refresh command. To verify it, You can run from the cmd:
replace XX with a ZWave node number You want to refresh the state for. If the command fires properly, than You should get "OK" response.
And one more thing: why do You think the command executes immediately ? Maybe You see the immediate change of a shutter level (in the GUI) just after You switch it ? If yes, than this is because OpenZWave sends a 'get' command just after the 'set' one. It doesn't mean afterSec does not work as expected
Code: Select all
FOR HTTP:
curl -k -d 'fun=racp&node=XX' -X POST http://127.0.0.1:8080/ozwcp/refreshpost.html
FOR HTTPS:
curl -k -d 'fun=racp&node=XX' -X POST https://127.0.0.1/ozwcp/refreshpost.html
And one more thing: why do You think the command executes immediately ? Maybe You see the immediate change of a shutter level (in the GUI) just after You switch it ? If yes, than this is because OpenZWave sends a 'get' command just after the 'set' one. It doesn't mean afterSec does not work as expected
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
I've just noticed, that refreshpost does not work until OpenZWave control panel or ZWave Controller hardware page has been opened
So, for the above solution to work, OZW has to be somehow initialized (maybe to build internal data structure or something ).
To make it work after each domoticz restart, I've wrote simple script, that fires on domoticz start (needs only to run once after each restart):
XX has to be replaced with the id of ZWave controller device. Sleep delay should be adjusted to allow all ZWave nodes to be queried during startup (look for "Status: OpenZWave: All Nodes queried" in domoticz.log).
So, for the above solution to work, OZW has to be somehow initialized (maybe to build internal data structure or something ).
To make it work after each domoticz restart, I've wrote simple script, that fires on domoticz start (needs only to run once after each restart):
Code: Select all
return {
on = {
system = {
'start'
}
},
execute = function(domoticz, triggeredItem)
domoticz.log('Initializing OpenZWave helpers in 70sec')
os.execute('(sleep 70; curl -ks -d "type=openzwavenodes&idx=XX" -X POST https://127.0.0.1/json.htm > /dev/null )&')
end
}
-
- Posts: 15
- Joined: Friday 26 July 2019 10:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Melun France
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Hi,
I'm verry interested in a solution to solve this problem with FGR223. So, I tried your solution but I have a problem when testing the refresh in my cmd :
An idea what's wrong ?
Edit :
i found out : the pi wasn't in the "white list" in my settings.
I'm verry interested in a solution to solve this problem with FGR223. So, I tried your solution but I have a problem when testing the refresh in my cmd :
Code: Select all
I tried :
sudo curl -k -d 'fun=racp&node=10' -X POST http://192.168.1.45:7781/ozwcp/refreshpost.html
Code: Select all
Result :
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Edit :
i found out : the pi wasn't in the "white list" in my settings.
Domoticz v2021.1 on Raspberry Pi 3B+
Raspbian Buster
ConBee II + Xiaomi devices
Zwave
Raspbian Buster
ConBee II + Xiaomi devices
Zwave
-
- Posts: 27
- Joined: Sunday 22 March 2020 17:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Glad You figured it out If You don't want to add it to "white list" just add authorization (user/pass) to the curl parameters.
Re: Fibaro Roller Shutter percentage issue (FGR-223)
Hello,
I think AfterSec is not working since log reports a notificacion inmediately to the event:
Sorry for my ignorance but where "white list" is configured? I run "sudo curl -k...." but I get the message
Thanks for your support.
edit: I have found where to include white list ip in domoticz configuration.
I think AfterSec is not working since log reports a notificacion inmediately to the event:
Code: Select all
2020-04-17 16:11:59.377 Notification sent (http) => Success
2020-04-17 16:11:59.676 Notification sent (http) => Success
Code: Select all
<html><head><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
edit: I have found where to include white list ip in domoticz configuration.
Who is online
Users browsing this forum: No registered users and 0 guests