Closed dumpfheimer closed 2 months ago
BTW I'm using pyvlx 0.2.16
Hello dumpfheimer,
could you explain how have you added the "tilt position" to HA exactly? I have also venetian blinds with Somfy motors but I can not change the "tilt position" via HA. I can move them only up and down via HA. Have you modified the the velux component? Could you share your code to add the "tilt position" to a venetian blind?
Hi!
You are right. HA currently does not support that. I have built it myself but have not yet tested it (especially the close tilt and open tilt correctness) and am not sure about the contribution guidelines so I did not dare to create a merge request YET.
Take a look at my changes here if you want to try it yourself: https://github.com/dumpfheimer/core/commit/1f5006d47768e5b27ca33081794154eb6f77203c
Hi!
I tried to investigate the values but I didn't really get smart from them. I wrote a script, that changes the orientation and reads back the response fp3 values. I put them in a CSV maybe somebody gets an idea of what could be going on.
For tilt position the HA integration has to be adjusted. pyvlx already support that since #33 . For testing you can use my HACS custom component where I already modified HA integration slightly, but not yet as a final solution to create a pull request to velux integration.
I didn't modified HASS yet, as the tilt function has two different options in terms of implementation, depending on the blinds. At somfy tahoma there was the possibility to configure blinds as either as (+90°/-90°) blinds or 0-100 %. The difference is in the code. Both covers requires a value between 0 and 100 for the tilt position, but the blinds with (+90°/-90°) are open at 50% and close at either 0% (=+90°) or 100% (=-90°) while the others are open at 0% and closed at 100% (inverted logic as in HA). In order to catch these different types of blinds, for each blind an additional configuration step is necessary to give the user the possibility to set the correct blind type. My exterior venetian blinds are from type (+90°/-90°), so I hard coded them to be open at 50 and close at 100. This is currently implemented at
and called from HA via:
However if you install custom component you can modify config\custom_components\my_velux\cover.py as follows to manually define the position_percent at which the cover is open/close
async def async_open_cover_tilt(self, **kwargs):
"""Open cover tilt."""
orientation = Position(position_percent=0)
await self.node.set_orientation(orientation=orientation, wait_for_completion=False )
async def async_close_cover_tilt(self, **kwargs):
"""Close cover tilt."""
orientation = Position(position_percent=100)
await self.node.set_orientation(orientation=orientation, wait_for_completion=False )
My HACS custom component: https://github.com/pawlizio/my_velux
Hi!
I modified the Hass code as posted above: https://github.com/dumpfheimer/core/commit/1f5006d47768e5b27ca33081794154eb6f77203c
The problem is not setting the orientation - that works fine. The problem is that it seems like the blinds are not sending the correct orientation when sending a status update. Do you have any information on that topic?
You mean that you set them to 100 %, but they confirm their position at 28%?
But just for clarification, physically they are at 100%?
What is reported if you set them to another value like 25% or 30%?
Yes, exactly. I intend to e.g. close the blinds with a 45° orientation. The blinds act exactly right and stay in the desired state. But the values reported back in fp3 are random other values that have nothing to do with the current orientation. Furthermore I wrote a script that set the orientation from 0-100 and displayed the responses in binary form. Ignoring the timestamp and checksum I was able to find exact the same responses from varying orientations which lets me believe the blinds do not send the orientation with the status update frame. Or it is hidden very well (within the timestamp for example. Those are not real timestamps)
Any suggestions what I could try?
If you can't find any systematic within the feedback I only can suggest to ignore the feedback from the KLF with regards to orientation (fp3 value). In this case you would always have the latest status which you set via home assistant.
I do have a Somfy connexoon AND the velux klf 200. The Somfy App does show the correct orientation. Should I be able to see the traffic between blind and connexoon on the klf200? Maybe I can identify a new frame.
Actually all frames which are submitted by KLF200 should be visible as pyvlx debug messages.
And frames sent between connexoon and the blind?
No, I mean if you activate the debug mode you will see all available frames submitted by KLF. But you will not see the whole io-homecontrol communication, only the abstract which is provided by KLF200.
Okay, too bad. Thank you, though. I guess I will try it anyways and hope the blind might send a broadcast message or something similar that contains a hint.
How would I enable debug mode?
Enable logger for pyvlx at your configuration.yaml as follows:
logger:
default: warning
logs:
pyvlx: debug
Danke!
Does anyone have a contact from somfy or velux whom I could ask about this? I tried to contact them but never got a response.
@pawlizio is my assumption correct, that you have venetian blinds too? If so, is the second byte you receive as FP3 always 00?
I am trying to find a workaround for the random values of somfy blinds. My first try would be to ignore the value if the first byte is a position and the second byte is not 0x00
@dumpfheimer yes I have exterior venetian blinds. If I set the orientation in HA the KLF always confirm only F7FF, which is defined as target valux, but pyvlx ignore this, because only values between 0 and 100% are accepted. I also don't get values on HA if I change the orientation with my remotes. But I have no random values as feedback or at least I never observed them.
Hello,
I installed yesterday my new KLF200 with latest firmware as well as the Velux HA custom component from pawlizio. First, thanks a lot for the great contribution! However, I'm facing the same problems as dumpfheimer with my venitian blind (Warema exterior venitian blinds with Somfy IO Home control module integrated). I can perfectly control the orientation of the blades with both my remote control (Somfy Situo 5) and HA. But as current_position, I randomly get either 28% or 75%. Is there any update on this issue?
Thank you!
Hi!
Nothing new on my side. I set this aside for now even though its annoying me. If more people are having this issue it might be better to ignore the FP3 from the venetian blinds all along and just cache the last set value. This of course should only happen if there are no users that actually get useful feedback on FP3, but I dont know how we could find out if such blinds exist.
There must be some kind of way to actually get the current position, because the somfy connexoon does load the right angle if you change it by eg a remote control. But I'm afraid that would be a huge trial and error mess. I wrote Velux and Somfy asking for help but neither even bothered to answer me.
Hi,
In the meantime, I started to work on it. The problem comes from the frame received by the HouseMonitoring function in KLF 200 which is used for example by Home Assistant to update Main Parameter (position) and Functional Parameter (FP3 : orientation). The notification frame received periodically from HouseMonitoring contains correct values for Main Parameter but total abberant values for Functional Parameters (FP1-FP7). In our case, we get for the slats orientation values that are either UNKNOWN, 26% or 73%.... I assume this is a bug in the Velux KLF 200 API and since there is no more support, we have to find another way. Fortunately, after some testing, there is a command that delivers the correct Functional Parameter values: GW_STATUS_REQUEST_REQ. I implemented this command in a local copy of Pyvlx this week-end and I'm still testing it. So far, I can get the correct orientation of the slats in Python debugger but finding a solution to call the GW_STATUS_REQUEST_REQ command within the HouseMonitoring seems to be tricky. I will continue to work on it and when a solution is found, I will submit the code for acceptance by Julius2342.
Glad to test it if you check in your changes.
And thank you for figuring this out!
Hi dumpfheimer,
I finished the code implementation. I had to put the GW_STATUS_REQUEST call in the Hearbeat loop because if call when receiving GW_NODE_STATE_POSITION_CHANGED_NTF (House monitoring frame), then the KLF200 send another GW_NODE_STATE_POSITION_CHANGED_NTF frame and we end in an infinite loop.
I tested it on my side in Home Assistant and it is working well. It would be great if you could also test it on your side. You will find the code in my repository Nicks/pyvlx (master branch).
Thank you!
sorry, I must have missed an email. I will test it as soon as possible, thank you!
Okay, I'm not home, but everything seems to be working normally and I am not getting randomly jumping values for tilt when I change the tilt position. So this looks like an improvement already. When I'm back I will test changing the orientation with the remote and see what happens.
Thank you for the first feedback. The tests with the remote were successful on my side. Orientation is updated every minute since the status is called from the heartbeat loop.
In the mean time I will finished the unit tests to be ready to make a pull request if the tests on your side are successful.
Hello Nicks57, thank you very much for the good work! I would also like to test the tilt function as I've been looking for a fix for a long time. I already use https://github.com/pawlizio/my_velux as a custom_component. How can I install your pyvlx library there? When could your solution get into the official version? Can I help you somewhere? ;)
Sorry I completely lost this out of sight. I had some issues with the branch. If I remember correctly it stopped working after 30s which, I believe, is the heartbeat interval. But I cannot even say that the cause is in the branch itself because I have modified HA and especially VELUX component. Sorry for never getting back to you
Hello!
@stephanseitz Thank you! To use my version of repository, you will need to change the "requirements" line in the manifest.json file in the custom component. Replace it with this:
"requirements": ["git+https://github.com/Nicks57/pyvlx.git@master#pyvlx==0.2.20"]
This means that HA should load my repository if there is no version 0.2.20 of pyvlx (actual version is 0.2.19).
I am working with a Velux custom component that is a copy of the HA core component (https://github.com/home-assistant/core/tree/dev/homeassistant/components/velux). I cannot garantee that it will work with the custom component of pawlizio but at far as I can see, it should.
The solution may go to the official version if we have multiple successfull tests for different people and if the solution is accepted. As I explained above, there is a bug in the Velux KLF200 API that delivers wrong values for FPX parameters when using the House Monitoring function. The solution to put the status update in the Heartbeat loop is not 100% "clean" since it is only a work around and may not be accepted from Julius2342.
You can help by testing on your side and give us the feedback. It will also be interesting to know which kind of actuator you have (I have Somfy Exterior Venetian blind Type 17).
@dumpfheimer Thank you for your feedback. On my side, I use the code without any change (I'm quite busy renovating a house :-) ) since the end of August and it is working even with HA running for weeks without restart. But it could be an isolated working case on my side so it is definitely good if other people can test it.
Hello nicks57, Hello dumpfheimer, thank you very much for your quick answers! I've just installed and tested the version. It works great! Much more usable than before. If I change the position manually with a hand-held transmitter, it takes a while until it is up-to-date in Homeassistant, but this is still better than with the tahoma api (official and unofficial). I have the Somfy J406 io PROTECT motors (24 pieces) in use (it says on the nameplate, can also send you a photo of the nameplate by pm).
Thank you for you feedback. I still need to write some unit tests, which may take some times. Then I could try to make a pull request. In the meantime, maybe we could have a chance for other people to test this solution.
While your are talking about Tahoma, I have another question that has been on my mind for a while and you can probably help me. When I use the remote control (Somfy Situo 5) and close the venetian blinds completely, the orientation of the blinds is set to 100% (closed, no light). When I open the venetian blinds completely, the orientation of the blinds is set 50% so that there are fully "wrapped" and not overlap the top of the window. If I close or open the venetian with HA, I don't have this effect. Especially when opening fully, the orientation is then 100% (or 0%) and the venetian is not fully "wrapped". So my question is, do you have a Tahoma with the Somfy app, and if so, what is the behavior when you close or open the venetian completely? Maybe we can improve something here.
Thank you!
I have a Tahoma Box and mainly used the Somfy app due to the previous problems with the API. Today I compared both ways and moved the blinds up and down several times. I couldn't see any real difference in behavior. The end position (open as well as closed) is the same for both ways. Even when the blinds are fully open, they disappear in the same place in the box. Either my motors are configured differently or unfortunately I did not understand your question. Maybe you can send me photos with notes too? Thanks very much
Should we keep an "orientation" flag within the abstraction?
@Nicks57
While your are talking about Tahoma, I have another question that has been on my mind for a while and you can probably help me. When I use the remote control (Somfy Situo 5) and close the venetian blinds completely, the orientation of the blinds is set to 100% (closed, no light). When I open the venetian blinds completely, the orientation of the blinds is set 50% so that there are fully "wrapped" and not overlap the top of the window. If I close or open the venetian with HA, I don't have this effect. Especially when opening fully, the orientation is then 100% (or 0%) and the venetian is not fully "wrapped". So my question is, do you have a Tahoma with the Somfy app, and if so, what is the behavior when you close or open the venetian completely? Maybe we can improve something here.
Within Tahoma portal you can adjust your blinds to the following illustrated options:
When I extended pyvlx for blind tilt functionality, I didn't consider those options and just hard coded open orientation at 50% and close at 100%: https://github.com/Julius2342/pyvlx/blob/2ba267fdcd0ec83580a52783dac178c4c00e0ae8/pyvlx/opening_device.py#L262-L277
Those was OK for me, but maybe this should be made configureable to HA.
Hi!
I installed it again and this is the error I am getting:
2021-10-26 08:52:25 DEBUG (MainThread) [pyvlx] SEND: <FrameStatusRequestRequest session_id="7" node_ids="[7]" status_type="StatusType.REQUEST_CURRENT_POSITION" fpi1="254" fpi2="0"/> 2021-10-26 08:52:25 DEBUG (MainThread) [pyvlx] REC: <FrameStatusRequestConfirmation session_id="7" status="StatusRequestStatus.ACCEPTED"/> 2021-10-26 08:52:25 ERROR (MainThread) [homeassistant] Error doing job: application protocol failed to receive SSL data Traceback (most recent call last): File "/usr/lib/python3.9/asyncio/sslproto.py", line 545, in data_received self._app_protocol.data_received(chunk) File "/srv/homeassistant/lib/python3.9/site-packages/pyvlx/connection.py", line 52, in data_received frame = frame_from_raw(raw) File "/srv/homeassistant/lib/python3.9/site-packages/pyvlx/api/frame_creation.py", line 51, in frame_from_raw frame.from_payload(payload) File "/srv/homeassistant/lib/python3.9/site-packages/pyvlx/api/frames/frame_status_request.py", line 168, in from_payload self.parameter_data.update({NodeParameter(payload[i]): Parameter(payload[i+1:i+3])}) File "/srv/homeassistant/lib/python3.9/site-packages/pyvlx/parameter.py", line 21, in __init__ self.raw = self.from_raw(raw) File "/srv/homeassistant/lib/python3.9/site-packages/pyvlx/parameter.py", line 67, in from_raw raise PyVLXException("parameter::raw_exceed_limit", raw=raw) pyvlx.exception.PyVLXException: <PyVLXException description="parameter::raw_exceed_limit" raw="b'\xd8\x00'"/>
it causes the connection to drop, so it is constantly reconnecting. If I find a quick fix I'll be back. ;-)
I will try making a branch that returns self.from_int(Position.UNKNOWN_VALUE)
instead of throwing an exception
Hi Guys,
Thank you for your replies. They partially answer my question. I'll be a bit clearer and take the scenario of the open venetian blind. When I send an open command to the venitian blind (not the slats, the whole blind) with the remote control, actually pressing the up button, the ventian blind opens fully and sets the slats orientation to 100% (not 50% as I mentionned in my previous post, is was a typo). This leads to having the venetian fully wrapped in its housing (or casing, don't now the correct english word, I mean the allumium cover where the whole mechanism/actuator is placed). If I use Home Assistant and send an open command, the venitan blind will open to position 100% but the slats orientation is set to other values than 100% (in my case I have two venitian blinds, on one the slats orientation is set to 50%, on the other 7%...).
Here some pictures to illustrate: Venitan Blind opened with remote control (orientation automatically set to 100%)
Venitan Blind opened with HA (orientation "automatically" set to 50%)
My question was how does the tahoma behave in the same scenario, i.e. if the open command is send, is the orientation also set to 100% like with the remote control.
In this case, it might make sense to update the pyvlx code to send a GW_COMMAND_SEND_REQ with the Main and FP3 Parameters to set the position and orientation to correct values when the open command is send. For now, only the main parameter is sent.
Hi! It is different with my blinds: When position is 0 I need to have the orientation at 100% for the slats to be fully enclosed in the box, and therefore invisible. If the position is 50% I see them from inside.
Other topic: I tested returning UNKNOWN instead of throwing an excecption and it seems to work! https://github.com/dumpfheimer/pyvlx/tree/position_parameter_fixes
I'm not sure this is the best approach, thogh. Maybe it would be better to add error handling (catching the exception) further up the stack?
According to the velux api documents there is a "default" value: 0xD300 maybe we can send that, when position is 0 and the blind itself will decied what is best? Page 102 in https://velcdn.azureedge.net/-/media/com/api/klf200/technical%20specification%20for%20klf%20200%20api-ver3-16.pdf
Ok, now I got it and yes this need to be adjusted. The blinds are completely closed if position and orientation is 100%. In pyvlx the current orientation will be transmitted as target orientation if the position is changed. What should be considered in case the target position is set to 100% that also the target orientation should be set to 100% in order to completely close the blinds. This is something I have in mind for a long time, but don't find the time for the implementation.
@dumpfheimer Same thing in my case, HA set the orientation to 50% and I can see partially the venitian blind from inside. On my side, position 0% is fully closed and 100% is fully open but maybe it depends on the venitian blind or the settings in the custom component. The problem is that your response frame has a parameter vaue of Hex D800 which is above the MAX Parameter defined in parameter.py. Could be interesting to debug and view the whole frame i.e. which parameter it is in the array. @pawlizio Thanks for the feedback. I might try to implement it in my fork if I find some time. It shouldn't be too complicated.
In HA is 100% fully open, but 100% in HA is 0 in pyvlx and reverse versa. That's always confusing.
Yes very confusing. I was always talking about HA UI :-)
@Nicks57 it looks like D800 is working for me (D300 is not) would you be willing to test if it retracts all the way with your blind?
https://github.com/dumpfheimer/pyvlx/tree/position_parameter_fixes
@dumpfheimer I have no access to the code for now, but why not using the hex value corresponding to 100% orientation in HA UI (i.e. C8 00 or 00 00 which correspond to MAX or MIN parameter)? Then we do not need the DEFAULT parameter.
I would be fine with that but I thought your blind would be positioned in a way that it shows out of the box 🤔
Servus!
Yesterday I started migrating my Home Assistant -> Somfy Connexoon to HA -> Velux KFL 200 which worked kind of nicely, but the "tilt position" (=orientation) was missing. So I went ahead and added that to HA.
Setting the orientation works flawlessly, but it always shows strange "current orientation" values. I then set pyvlx to debug and it seems like it is receiving those strange values from the blind. But I was hoping you could confirm that for me.
IF it is the blind, that is sending strange/unhandled signals, would it be possible to use the sent values as current values for this particular blind/product? It did show the right position in the Somfy App. IF it is not the blind. Do you have any idea what those values could mean? I went through the code and came to the conclusion it actually is within the "position range" which - I guess - would mean it would be a pretty inconvenient "special value"
I appreciate any help.
Vielen Dank!
I copied 2 debug logs from when I tried to set the orientation (it did set it correctly)
EXAMPLE 1
EXAMPLE 2