cornim / wms_webcontrol

A library to control a Warema WMS WebControl web server.
GNU Lesser General Public License v3.0
15 stars 6 forks source link

Warema WMS and Home Assistant #1

Closed Stephan1908 closed 3 years ago

Stephan1908 commented 4 years ago

Hello Mr. Mund, In my house, I used the Warema WMS system with 3 shutters and 7 external blinds. I would like to integrate the WMS system into my Home Assistant system. I can't find anything on the internet, but today I found your example in Python. Can you tell me if it works with Home Assistant? Then I would buy the Warema WMS WebControl web server. Do you have any tips for me? I'm unfortunately a beginner in terms of integrating and especially Python. Sincerely yours Stephan from Germany :-)

cornim commented 4 years ago

Sorry, I didn't see this earlier. Yes it works with home assistant and I even have an integration for it. Best

cornim commented 4 years ago

It only supports vertical blinds right now, though, as I don't own anything else.

Stephan1908 commented 4 years ago

Hi, thanks for the answer. I have bought a webcontrol and will test it soon. I hope I can do it. greetings

Stephan1908 commented 4 years ago

Hi, so, I've tried a lot now, but unfortunately I'm not getting anywhere. I have copied the python files (shade, init and wms_controller) into my Python scripts folder. after restarting home assistant I get the services from developer tools. If I enter the following into service data:

self.wms_ctrl: wms_ctrl self.room: children's room self.channel: children's room self.time_between_cmds: 1 self.num_retries: 3 self.position: 50 self.is_moving: is_moving self.state_last_updated: None

Nothing happens. can you tell me what i did wrong? My WebControl server is under http://webcontrol.local. Thank you very much. Greetings

cornim commented 4 years ago

Hi, to access these scripts from home assistant you need to write an integration. https://developers.home-assistant.io/docs/creating_component_index/

Stephan1908 commented 3 years ago

Hello Mr. Mund, I tried to create an integration, but I can't do it. I'm not fit for it. Can you maybe help me with the integration? I have the Hello_state.world integration from the link above. If I copy the files from you into the folder config\custom_components\warema_wms and make the call in my Configuration.yaml (warema_wms:) I get the following error message: Component error: warema_wms - Integration 'warema_wms' not found. Many Thanks. Greetings Stephan

cornim commented 3 years ago

Yes, I can help. I'll upload my integration to GitHub in the next weeks and then post the link here so you can use it.

cornim commented 3 years ago

I uploaded the integration here https://github.com/cornim/ha-warema-integration

Stephan1908 commented 3 years ago

Hi, thank you very much. I copied the folder warema_wms_webcontrol to \config\custom_components and added warema_wms_webcontrol: to my configuration.yaml. When I check the configuration, I get an ok. When I restart Homeassistant, I get the message: The following integrations could not be set up: warema_wms_webcontrol Please check your config. I compared the integration with existing integration, but unfortunately I cannot find any connections. I think I don't have the libraries (shade.py and WmsController) in the right place (I have these in the same folder as the integration) and / or something is still missing in the configuration.yaml. Unfortunately it is very time-consuming and very complicated for me as a beginner to integrate the Warema, but I have no other solution, so I try to fight my way through here. In any case, a big thank you for the help so far. greetings

cornim commented 3 years ago

You have to install the warema library via pip.

pip install warema-wms-controller

Stephan1908 commented 3 years ago

Hi, Thanks for the tip. I think I now know where my problem is. I'm using HassOS, if I've read correctly, the "pip install" command doesn't work here. I would have to set up my Home Assistant again, but not with the HassOS image, but in a virtual environment (Home Assistant Core). Greetings

cornim commented 3 years ago

That might be. I don't really know anything about HassOS. Best of luck.

siggy2 commented 3 years ago

@Stephan1908 you need to make sure to include:

you need to make sure you have this in your configuration.yaml:

python_script:

and then using the cover platform: ('warema_wms_webcontrol:' will not give you anything)

cover:

you alos might want to add

logs: warema_wms_webcontrol: debug homeassistant.components.warema_wms_webcontrol: debug

for debug info.

Before restarting HA, you need to add a folder under config/custom_components, called warema_wms_webcontrol with the HA integration files from cornim

under config you need to create a folder called python_scripts (if it isn't there already) and then in that folder a new folder called warema_wms where you copy the warema_wms files from cornims core folder.

Hopefully this puts you on a working path for this.

oywino commented 1 year ago

Sorry to jump in so late. I too am trying to get this working and everything seems pretty much straight forward but I can't get it to run successfully. Any assistance is highly appreciated. Here's my configuration.yaml:

python_script:
  warema_wms:

cover:
  - platform: warema_wms_webcontrol
    webcontrol_server_addr: http://192.168.1.133
    update_interval: 300

Here's the content of my _config/custom_components/warema_wmswebcontrol folder:

image

And here's the content of my _config/python_scripts/waremawms folder:

image

HA report configuration as valid, but during restart I get this errors in the log:

Logger: homeassistant.components.cover
Source: custom_components/warema_wms_webcontrol/cover.py:25
Integration: Cover (documentation, issues)
First occurred: 8:10:26 PM (1 occurrences)
Last logged: 8:10:26 PM

Error while setting up warema_wms_webcontrol platform for cover
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 39, in _retrieve_setup
    room_xml = self.send_rx_room_name_command(room_id)
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 84, in send_rx_room_name_command
    return self._send_command(RX_ROOM_NAME, format(room_id, '02x'))
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 78, in _send_command
    return ElemTree.fromstring(r.text)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1344, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/warema_wms_webcontrol/cover.py", line 25, in setup_platform
    shades = Shade.get_all_shades(WmsController(config[CONF_WEBCONTROL_SERVER_ADDR]), time_between_cmds=0.5)
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 62, in __init__
    self.rooms = self._retrieve_setup()
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 55, in _retrieve_setup
    self.send_rx_check_ready()
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 105, in send_rx_check_ready
    return self._send_command(RX_CHECK_READY, format(room_id, '02x') + format(channel_id, '02x'))
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 78, in _send_command
    return ElemTree.fromstring(r.text)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1344, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

Rgds Viking

thesaint1975 commented 1 year ago

at least at my setup it works with the following:

configuration.yaml:

python_script:

without warema_wms

cover: platform: warema_wms_webcontrol webcontrol_server_addr: http://xxx.xxx.xx.xxx update_interval: 300

send from my mobile, so indentations maybe wrong, but i think HA assists you here

config/custom_components/warema_wms_webcontrol folder looks ok for me

config/python_scripts/warema_wms folder looks suspicious the folder should look like

Screenshot_20220719-082235_Home Assistant

and in there, config/python_scripts/warema_wms/warema_wms

Screenshot_20220719-082256_Home Assistant

hope this helps cheers

cornim commented 1 year ago

it looks like, whatever is being returned by your web control server isn't well formed xml.

Please enable debug logging to see what is being returned from the server.

oywino commented 1 year ago

Hello Dr. @cornim - thanks for stopping by 👍 I did exactly what @thesaint1975 suggested, but it made no difference. The error messages reported during startup is as follows:

Logger: homeassistant.components.cover
Source: custom_components/warema_wms_webcontrol/cover.py:25
Integration: Cover (documentation, issues)
First occurred: 11:12:20 AM (1 occurrences)
Last logged: 11:12:20 AM

Error while setting up warema_wms_webcontrol platform for cover
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 39, in _retrieve_setup
    room_xml = self.send_rx_room_name_command(room_id)
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 84, in send_rx_room_name_command
    return self._send_command(RX_ROOM_NAME, format(room_id, '02x'))
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 78, in _send_command
    return ElemTree.fromstring(r.text)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1344, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/warema_wms_webcontrol/cover.py", line 25, in setup_platform
    shades = Shade.get_all_shades(WmsController(config[CONF_WEBCONTROL_SERVER_ADDR]), time_between_cmds=0.5)
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 62, in __init__
    self.rooms = self._retrieve_setup()
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 55, in _retrieve_setup
    self.send_rx_check_ready()
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 105, in send_rx_check_ready
    return self._send_command(RX_CHECK_READY, format(room_id, '02x') + format(channel_id, '02x'))
  File "/usr/local/lib/python3.10/site-packages/warema_wms/wms_controller.py", line 78, in _send_command
    return ElemTree.fromstring(r.text)
  File "/usr/local/lib/python3.10/xml/etree/ElementTree.py", line 1344, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

My attempt to enable debug logging is as follows:

logger:
  default: warning
  logs:
    custom_components.warema_wms_webcontrol: debug
    homeassistant.components.cover: debug
    homeassistant.components.python_script: debug
    warema_wms: debug

Apparently, only the homeassistant.components.cover: debug resulted in anything being logged. The log can be found here: https://pastebin.com/TM5SZtYS

Please advise.

cornim commented 1 year ago

As I have guessed the response you are getting is not the expected response. You get some html page back instead of the expected xml.

Why that is I can only guess. What happens if you open the page manually. i.e.

http://<ip of you webcontrol>/protocol.xml?protocol=9000020300&_=1658223995

Maybe this helps us determine the reason behind this error.

oywino commented 1 year ago

What happens if you open the page manually. i.e.

http://<ip of you webcontrol>/protocol.xml?protocol=9000020300&_=1658223995

All that happens is that I get redirected to : http://192.168.1.133/system which is the same as the default opening page of the WebControl server.

thesaint1975 commented 1 year ago

just to be sure, do you have the WebControl or the WebControl Pro Box?

oywino commented 1 year ago

just to be sure, do you have the WebControl or the WebControl Pro Box?

I have the WebControl Pro box

Pferdebockwurst commented 1 year ago

just to be sure, do you have the WebControl or the WebControl Pro Box?

I have the WebControl Pro box

That one doesn't work with this plugin.

oywino commented 1 year ago

@Pferdebockwurst - I can only assume that you are right about that. So, the question then is; Can @cornim fix that (or anyone else)? I am regretfully not a programmer myself, but I'd love to be a beta-tester 🙂

cornim commented 1 year ago

Since the communication protocol was reverse engineered only someone with the WebControl Pro could reverse engineer the communication with that one and extent this plugin.

oywino commented 1 year ago

So, even with guidance from someone with the right knowledge - such as yourself, I couldn't do it?

cornim commented 1 year ago

That very much depends on your proficiency with HTTP get call reengineering and Python programming. Of course I can explain to you how I did this for the WebControl but it requires at least some technical skill and it might work differently for the WebControl Pro and since I don't own one of these, I cannot have a look myself.

oywino commented 1 year ago

I contacted Warema and inquired about API information. Still waiting. Has anyone else tried to contact them? Do we know their attitude with regards to third party integrations?

Pferdebockwurst commented 1 year ago

I once mailed them about that topic. My mail got right to the developer who posted at the homee forums (because they have produced a homee cube to integrate it in that ecosystem). Never got a response. Please keep us updated, if you get a response.

oywino commented 1 year ago

My mail got right to the developer who posted at the homee forums (because they have produced a homee cube to integrate it in that ecosystem)

Do you have a link to the post on the Homee Forum? If they have published an API for the Homee, wouldn't it be possible to use that also for HA ?

Pferdebockwurst commented 1 year ago

My mail got right to the developer who posted at the homee forums (because they have produced a homee cube to integrate it in that ecosystem)

Do you have a link to the post on the Homee Forum? If they have published an API for the Homee, wouldn't it be possible to use that also for HA ?

Homee is not open source.

Edit: I don't remember the exact forum posts, but look at this thread in the homee forums: https://community.hom.ee/t/warema-wms-cube/34917/25

WAREMA_Stefan was the guy I mailed to.

oywino commented 1 year ago

Coming back to this issue - trying to figure out how to reverse engineer the WMS Web Control Pro. I tried using Cordova but the data from the controller seems to be heavily encrypted and couldn't be read. I also talked to a Warema representative, and they have no plans to release any info about the API. It is sad that this company thinks an open attitude will hurt sales. Cause it won't. Quite the contrary. If decided to cooperate with the commmunity, thay would most likely see sales go up significantly. As it is now, I cannot recommend Warema to anyone with a Home Assistant installation.

ColomboEnterprise commented 1 month ago

Hi, i try to integrate my WMS installation i have the normal old Box and usb stick. Only Shutters are in the webcontrol I have add in the config file:

` python_script:

cover: platform: warema_wms_webcontrol webcontrol_server_addr: http://192.168.178.50

update_interval: 300

warema_wms_webcontrol: debug homeassistant.components.warema_wms_webcontrol: debug ` But get the message after reboot: The warema_wms_webcontrol integration does not support configuration via a YAML file.

I have copy and created all the files from: thesaint1975 Download from GitHub: warema-wms-controller-0.2.4 wms_webcontrol-master and installed manually.

Someone know what is missing?

cu