slesinger / pybmr

Python library for controling BMR HC64 heating
https://shop.fenixgroup.cz/z4770-bmr-hc-64-ridici-jednotka
Apache License 2.0
0 stars 3 forks source link

blinds support #15

Open zelial opened 8 months ago

zelial commented 8 months ago

The BMR control unit is able to control blinds ("venkovni žaluzie"). The controls are exposed via web UI similarly as heating ones are. Would be nice to have support for them in pybmr (so that it can then be added to Home Assistant as well).

zelial commented 8 months ago

As per https://www.home-assistant.io/integrations/cover/ what this is about are not shutters but blinds.

Dehumanizer77 commented 8 months ago

@vsechnozabrany in reply to https://github.com/slesinger/HomeAssistant-BMR/issues/7#issuecomment-1972638388, yes, I know, actually you don't have to access the service menu, you just need to set the corresponding bit via modbus, but otherwise it's as you said.

Anyway, the approach with actually logging in to the web interface and changing values there is fine, plus you won't lose the manual control via the web interface as with the modbus approach, so adding a support for blinds would be great.

slesinger commented 7 months ago

Blinds support will be problematic for me as I do not have external blinds controlled by BMR. Can you do me a favor to show how XHR requests look? Login to your local BMR web interface with Chrome. Open Developer Tools > Inspect > Network > XHR. Then browse through the web UI, visit list of blinds and move one up/down. Finally, right click in the inspector "Save all as HAR with Content" and attach it here. (your password will not be here if you opened Inspect after login screen). Thank you.

Dehumanizer77 commented 7 months ago

Sure, here it is. Also with screenshots so that you know how it looks like. The "natoceni" which you see on the screenshot is not used in my case, as I have regular roler blinders, it is used with venetian blinds (rolety vs. zaluzie). Screenshot at 2024-03-23 16-17-24 Screenshot at 2024-03-23 16-14-18 har.zip

slesinger commented 7 months ago

Thank you. Can you please specify what is the very minimal viable set of features?

Dehumanizer77 commented 7 months ago

I think if you just added setting the blinds via manual setting and reading the status (but I didn't browse to the status page so you would probably need that too), it would be a good start, then you can set up schedule using automations.

zelial commented 7 months ago

@slesinger I have blinds and was planning to (eventually ;) ) code the support myself. But if somebody else does it I wouldn't mind :)

The idea was to use the internal API the webUI uses, similar to how heating is controlled. E.g.

curl -X POST http://bmr.zelial.cz/saveManualChange -H 'Content-Type: application/x-ww-urlencoded; charset=UTF-8' -d 'manualChange=04710'

The numeric parameter represents the blind ID to be controlled [0-1], position[2] and tilt [3].

The position has only 4 values so the blinds can't be controlled precisely (e.g. set to 56%) and BMR doesn't expose the dumb low-level controls to the motors so we'd have to make do with this. But it's sufficient for most my use-cases.

zelial commented 7 months ago

Also BMR blinds only have 8 programs available so supporting manual change via switching to a different program isn't feasible (unlike with heating which AFAIK has 32 programs). So my plan was to expose just the manual change interface and not the programs.

zelial commented 7 months ago

Here are my notes for the manualChange parameter:

manualChange format:

slesinger commented 6 months ago

Thanks @Dehumanizer77 and @zelial for providing details. I have blindly implemented blinds support in this package (I need to extend HA package, too). I still need some more info from you.

  1. API /wholeRollerShutter returns a cryptic value like 1Kuchyna 0000010000000000000. Can you experiment and try to decode what the long number means?
  2. API /windSensorStatus returns a cryptic value like 0000000001111111111111111111111111111111100000000000. Can you experiment and try to decode what the long number means?
  3. Is API /rollerShutterIntermediate any good?

Latest master (4a7cc02a05489af2d898b509d609355938d0f7c2) contains my changes in case you want to play with that. Or wait for the HA package.

Dehumanizer77 commented 6 months ago

How do I test the API?

zelial commented 6 months ago

I don't have the windsensor so can't test that but I'll try to decipher the /wholeRollerShutter and test your changes.

Dehumanizer77 commented 6 months ago

If you can explain me how do I get to this API, I can ask the someone from BMR (the manufacturer), I know people there, they will surely be able to help.

slesinger commented 5 months ago

I cannot show it on my BMR but the API is called in recorded session. You can download above har.zip and unzip. Next, open Chrome browser, right-click, Inspect, Network, Import HAR file (shown on screenshot) image I am sure when somebody from BMR will see it, will be able to tell what the output "0000010000000000000" actually means. Similar issue is with the other APIs `/windSensorStatus and /rollerShutterIntermediate. Thank you

Dehumanizer77 commented 5 months ago

ok, I am quite busy right now, but in two weeks I am going to a vacation, so I'll take a look

zelial commented 3 months ago
  • API /wholeRollerShutter returns a cryptic value like 1Kuchyna 0000010000000000000. Can you experiment and try to decode what the long number means?

I've tested and documented it in #21.

Dehumanizer77 commented 3 months ago

I'm sorry, it's really hard with a 6-months old kid on a vacation, I didn't have time at all :-)

zelial commented 3 months ago

Latest master (4a7cc02) contains my changes in case you want to play with that. Or wait for the HA package.

I've tested the code. saveManualChange works well (thanks!) but the value mapping is quite unintuitive. Tilt is mapped from 0-10 to 0-100 for some reason and position is mapped from 0-100 to 100-0 i.e. reversing the meaning. This broke my brain when using it. Is there a reason for not using the value ranges as bmr does? E.g. is this what Home Assistant expects?

vsechnozabrany commented 1 month ago

I cannot contribute on the code side, but I'd like to help with testing of blinds + I had pretty good contact to manufacturer. Is there anything I can help with?