h4de5 / VimarWebserverApi

DEPRECATED - use https://github.com/h4de5/home-assistant-vimar - Renders a website that is reading information from the VIMAR Bus Webserver and let you control simple switches.
1 stars 0 forks source link

Vimar by me and Alexa #1

Closed alfienero closed 4 years ago

alfienero commented 5 years ago

Hi Andi,

I have a vimar by me with webserver like you, I wonder if you succedeed in reaching some high level integration with Alexa or something similar.

Moreover, What can I do with your Vimar project?

Thank you, Gianluca

h4de5 commented 5 years ago

if you configure (rename config.ini_example to config.ini and adapt it) it correctly, you can read out the structure of the bus system and display it on a webserver using PHP:

image

It only offeres simple triggering (on/off switches) no dimming or up/down settings. I haven't done much since then - the plan was to add a better API to the websever in order to use it for alexa or google assistant. but the current state is far from that.

please also note, that I only have one such system - so I had to assume some standard values which my be different on your installation.

alfienero commented 5 years ago

Thank you very much for your detailed answer! Having the Vimar Web Server currently I will have no benefit, but please tell me if you will updrate with the new API, in case I can help you to test it with another Vimar installation

h4de5 commented 4 years ago

I moved on with this integration and ported it to python to be compatible with https://home-assistant.io In the future I will only focus on the new implementation and therefore will archive this repository.

Feel free to try it out if you have the chance: https://community.home-assistant.io/t/vimar-integration-wip/202073 https://github.com/h4de5/home-assistant-vimar

alfienero commented 4 years ago

Hi Andi!!!!!

Firstly thank you for remembering that I’m interested in this integration! In the end I solved buying a software from Ilevia running on raspberry pi3+ to achieve voice control integration with alexa. Anyway I’m interested in helping you and in integrating vimar in home assistant as well.

I cloned the repository in a subfolder located in custom components folder and I added in configuration.yaml the following

vimar_platform: username: Amministratore password: ** host: 192.168.1.110 schema: https port: 443 certificate: C:\Users\Gianluca\AppData\Roaming.homeassistant

But if I check the configuration.yaml in home assistant I got

Invalid config for [vimar_platform]: [username] is an invalid option for [vimar_platform]. Check: vimar_platform->username

Any suggestions?

Thanks, Gianluca

Il giorno 4 giu 2020, alle ore 23:18, Andi notifications@github.com ha scritto:

I moved on with this integration and ported it to python to be compatible with https://home-assistant.io https://home-assistant.io/ In the future I will only focus on the new implementation and therefore will archive this repository.

Feel free to try it out if you have the chance: https://community.home-assistant.io/t/vimar-integration-wip/202073 https://community.home-assistant.io/t/vimar-integration-wip/202073 https://github.com/h4de5/home-assistant-vimar https://github.com/h4de5/home-assistant-vimar — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4de5/VimarWebserverApi/issues/1#issuecomment-639121591, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKDWURRW2O7HP373NUH7CTRVAFRLANCNFSM4GUGJ7RA.

h4de5 commented 4 years ago

Hey. Glad you are still interested! Your config seems to be fine - just the certificate is a file path not a directory:

vimar_platform:
  username: Andreas
  password: *****
  host: 192.168.0.13
  schema: https
  port: 443
  certificate: /config/rootCA.VIMAR.crt

which version of home-assistant have you running? Is it hass.io on a rpi or within docker? the path seems windows'isch?

/ edit: the path to clone the github repository files to is either:

/config/custom_components/vimar_platform/ ... on docker/hassio

or

/home/homeassistant/.homeassistant/custom_components/vimar_platform/ .. on hassbian/virtualenv

alfienero commented 4 years ago

It’s a HA installed on windows through python (virtual environment I guess), version Home Assistant 0.109.6

I changed the configuration like this. Which is the subfolder name under custom_components? I also tried to rename it to “vimar_platform” instead of default "home-assistant-vimar-master”

vimar_platform: username: Amministratore password: ** host: 192.168.1.110 schema: https port: 443 certificate: \custom_components\vimar_platform\rootCA.VIMAR.crt

The issue is that in home assistant it says that the platform could not be loaded (it prompts as a notification after start-up) and if I check config I got:

Il giorno 5 giu 2020, alle ore 17:04, Andi notifications@github.com ha scritto:

Hey. Glad you are still interested! Your config seems to be fine - just the certificate is a file path not a directory:

vimar_platform: username: Andreas password: ***** host: 192.168.0.13 schema: https port: 443 certificate: /config/rootCA.VIMAR.crt which version of home-assistant have you running? Is it hass.io on a rpi or within docker?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4de5/VimarWebserverApi/issues/1#issuecomment-639551858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKDWURKWC45U3OZ4PT52U3RVECQTANCNFSM4GUGJ7RA.

h4de5 commented 4 years ago

Yeah. It looks like hass does not even find the component :( During startup you should get something like this:

WARNING (MainThread) [homeassistant.loader] You are using a custom integration for vimar_platform ..

Unfortunately I am no expert for venv on windows :( my guess is still on the wrong directory structure. I updated the readme on the new repository. Maybe this will help.

alfienero commented 4 years ago

Yes Andi, very strange, when I start up HA I got this.

I’ll do a little bit of advertising of your impressive work on HA italian facebook page, there are 2-3 people using vimar there maybe we can have more info with them.

Thanks anyway! Gianluca

Il giorno 5 giu 2020, alle ore 18:56, Andi notifications@github.com ha scritto:

Yeah. It looks like hass does not even find the component :( During startup you should get something like this:

WARNING (MainThread) [homeassistant.loader] You are using a custom integration for vimar_platform ..

Unfortunately I am no expert for venv on windows :( my guess is still on the wrong directory structure. I updated the readme on the new repository. Maybe this will help.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4de5/VimarWebserverApi/issues/1#issuecomment-639629698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKDWUT7RWLKAW7W525HFILRVEPUNANCNFSM4GUGJ7RA.

h4de5 commented 4 years ago

In case you are sending screenshots per email as answer to the GitHub emails: they are not getting displayed in the conversation .

A big thank you for that! Looking forward to more feedback ;)

h4de5 commented 4 years ago

the problem with the invalid config should be resolved.

alfienero commented 4 years ago

Hi Andi,

thank you for letting me know. Unfortunately I redownloaded che custom component and put in the vimar_platform folder, but I still get at HA start up

“The following integrations and platforms could not be set up:

vimar_platform https://github.com/h4de5/VimarWebserverApi/ Please check your config."

Tomorrow I’ll try to investigate a little bit further with logs.

Good night, GIanluca

Il giorno 7 giu 2020, alle ore 22:12, Andi notifications@github.com ha scritto:

the problem with the invalid config should be resolved.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4de5/VimarWebserverApi/issues/1#issuecomment-640273096, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKDWUWFMTX3H63BI4WOTS3RVPYDVANCNFSM4GUGJ7RA.

alfienero commented 4 years ago

Quick auto-reply: what is solved with the new release is the config error, now if I try to validate yaml on HA I don't get anymore the error on username as an invalid option. Unfortunately as I said before is not loading the component.

In the log I have the following lines, so maybe is wrong certificate location that is stopping the integration, could be so?

2020-06-07 23:40:27 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for vimar_platform which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. Traceback (most recent call last): File "C:\Users\Gianluca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\homeassistant\setup.py", line 171, in _async_setup_component hass, processed_config File "C:\Users\Gianluca\AppData\Roaming.homeassistant\custom_components\vimar_platform__init__.py", line 100, in async_setup if vimarconnection.installCertificate() == False: File "C:\Users\Gianluca\AppData\Roaming.homeassistant\custom_components\vimar_platform\vimarlink.py", line 63, in installCertificate file = open(self._certificate, "w") FileNotFoundError: [Errno 2] No such file or directory: '/home/homeassistant/.homeassistant/custom_components/vimar_platform/rootCA.VIMAR.crt'

Il giorno dom 7 giu 2020 alle ore 23:46 Gianluca Chiodini < gianluca.chiodini@gmail.com> ha scritto:

Hi Andi,

thank you for letting me know. Unfortunately I redownloaded che custom component and put in the vimar_platform folder, but I still get at HA start up

“The following integrations and platforms could not be set up:

vimar_platform https://github.com/h4de5/VimarWebserverApi/

Please check your config."

Tomorrow I’ll try to investigate a little bit further with logs.

Good night, GIanluca

Il giorno 7 giu 2020, alle ore 22:12, Andi notifications@github.com ha scritto:

the problem with the invalid config should be resolved.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4de5/VimarWebserverApi/issues/1#issuecomment-640273096, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKDWUWFMTX3H63BI4WOTS3RVPYDVANCNFSM4GUGJ7RA .

h4de5 commented 4 years ago

@alfienero please update the code again and try to remove the certificate config option. I added a default value for it. maybe it gets confused with / and . if you restart hass - it should download the vimar.crt file into .homeassistant and us it from there.

alfienero commented 4 years ago

Redownloaded code and cancelled in the configuration.yaml the certificate line, now is like this:

vimar_platform: username: Amministratore password: *** host: 192.168.1.110 schema: https port: 443

Log: 2020-06-08 11:22:25 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 11:22:25 INFO (SyncWorker_4) [custom_components.vimar_platform.vimarlink] Downloaded Vimar CA certificate to: rootCA.VIMAR.crt 2020-06-08 11:22:27 ERROR (SyncWorker_1) [custom_components.vimar_platform.vimarlink] Other error occurred: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'192.168.1.110\', port=443): Max retries exceeded with url: /vimarbyweb/modules/system/user_login.php?sessionid=&username=Amministratore&password=****&remember=0&op=login (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_server_certificate\', \'certificate verify failed\')])")))')) 2020-06-08 11:22:27 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry UPnP/IGD for upnp

While if I use for config vimar_platform: username: Amministratore password: *** host: 192.168.1.110

I get: 2020-06-08 11:29:26 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 11:29:26 ERROR (SyncWorker_4) [custom_components.vimar_platform.vimarlink] Other error occurred: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'192.168.1.110\', port=443): Max retries exceeded with url: /vimarbyweb/modules/system/user_login.php?sessionid=&username=Amministratore&password=****&remember=0&op=login (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_server_certificate\', \'certificate verify failed\')])")))')) 2020-06-08 11:29:26 ERROR (MainThread) [custom_components.vimar_platform] Could not connect to Vimar Webserver 192.168.1.110 2020-06-08 11:29:26 ERROR (MainThread) [homeassistant.setup] Error during setup of component vimar_platform Traceback (most recent call last): File "C:\Users\Gianluca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\homeassistant\setup.py", line 171, in _async_setup_component hass, processed_config File "C:\Users\Gianluca\AppData\Roaming.homeassistant\custom_components\vimar_platform__init__.py", line 110, in async_setup raise PlatformNotReady

h4de5 commented 4 years ago

which firmware version of the webserver do you have installed? image I haven't tried it with older versions.

if you usually connect to the webserver using http (instead of https) - you can force that by using: schema: http to the configuration.yaml

alfienero commented 4 years ago

I have the last, the same version you have: 2.5.0. (Rev.24863), just checked.

alfienero commented 4 years ago

Forcing schema: http the platform still not load

Below the log 2020-06-08 12:10:23 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 12:10:23 ERROR (SyncWorker_0) [custom_components.vimar_platform.vimarlink] HTTP error occurred: 400 Client Error: Bad Request for url: http://192.168.1.110:443/vimarbyweb/modules/system/user_login.php?sessionid=&username=Amministratore&password=*********&remember=0&op=login 2020-06-08 12:10:24 ERROR (MainThread) [custom_components.vimar_platform] Could not connect to Vimar Webserver 192.168.1.110 2020-06-08 12:10:24 ERROR (MainThread) [homeassistant.setup] Error during setup of component vimar_platform Traceback (most recent call last): File "C:\Users\Gianluca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\homeassistant\setup.py", line 171, in _async_setup_component hass, processed_config File "C:\Users\Gianluca\AppData\Roaming.homeassistant\custom_components\vimar_platform__init__.py", line 110, in async_setup raise PlatformNotReady

h4de5 commented 4 years ago

sorry. you may need to change the port as well: port: 80 I will have to clearify this better in the docs.

alfienero commented 4 years ago

I just tried with this config but the platform doesn’t set up unfortunately. According to logs, it seems to try to connect to port 443 even if I forced in the config 80

vimar_platform: username: Amministratore password: ***** host: 192.168.1.110 schema: http port: 80

Log: 2020-06-08 13:14:51 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 13:14:51 ERROR (SyncWorker_5) [custom_components.vimar_platform.vimarlink] Other error occurred: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'192.168.1.110\', port=443): Max retries exceeded with url: /vimarbyweb/modules/system/user_login.php?sessionid=&username=Amministratore&password=*****&remember=0&op=login (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_server_certificate\', \'certificate verify failed\')])")))')) 2020-06-08 13:14:53 ERROR (MainThread) [custom_components.vimar_platform] Could not connect to Vimar Webserver 192.168.1.110 2020-06-08 13:14:53 ERROR (MainThread) [homeassistant.setup] Error during setup of component vimar_platform Traceback (most recent call last): File "C:\Users\Gianluca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\homeassistant\setup.py", line 171, in _async_setup_component hass, processed_config File "C:\Users\Gianluca\AppData\Roaming.homeassistant\custom_components\vimar_platform__init__.py", line 110, in async_setup raise PlatformNotReady

Il giorno 8 giu 2020, alle ore 12:55, Andi notifications@github.com ha scritto:

sorry. you may need to change the port as well: port: 80 I will have to clearify this better in the docs.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/h4de5/VimarWebserverApi/issues/1#issuecomment-640530481, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKDWUR7VDBGUQNSMYTAW2LRVS7TLANCNFSM4GUGJ7RA.

h4de5 commented 4 years ago

if you connect to the webservers interface, do you use this url:

https://192.168.1.110/vimarbyweb/modules/system/externalframe.php

in that case schema: https and port: 443 should be fine. You can check the webserver under general settings > Setup > Network. the host field can either be the external hostname or the internal IP. is the bus-system reachable from within home-assistant network (maybe a question only interesting for docker environments..)

alfienero commented 4 years ago

Firtly thank you again for your patience. In the past I used https asking vimar a special certificate that maybe it got cancelled in some update. Now I'm having a problem with using the certificate in chrome both on windows and mac: it tells me that is impossible to verify the certificate because the releasing authority is not reliable. NET::ERR_CERT_COMMON_NAME_INVALID, but than I can proceed to unsafe page, so I guess I'm back in 80 port. On the other side using by web app for Iphone I don't have problems and I connect using 443 port.

If I have well understood the question I have only one router/gateway, the same I use for webserver (LAN) and HA (wi-fi). I have 2 wifi network I don't know if it could be an issue (2.4/5).

Cattura

h4de5 commented 4 years ago

with the latest firmware update (2.5) from the webserver, vimar updated the CA certificate as well. you can see the download link in your screenshot on the bottom.

This certificate needs to be installed into chrome or your operating system. this CA certificate will enable the server certificates which are re-generated by the webserver everytime when you change the ip or the public hostname - to be seen as valid. If you do so you should not get a warning from chrome or other browsers anymore.

the other thing is, that it seems the webserver is always forcing you to use https on port 443 - even if we try to connect to http on port 80. so this option became useless.

BUT - this should not bother the integration at all :) because it does all of this on its own. it downloads the ca-certificate from that link and tries to use it with any other subsequent call to the webserver. so as the host/ip seems to be fine, it should work :\

it seems the problem occurs during downloading the certificate it self. can you try the following: download the rootCA.VIMAR.crt from the link in that screenshot of yours. (should be: https://192.168.1.110/vimarbyweb/modules/vimar-byme/script/rootCA.VIMAR.crt ) put that file into your configuration folder (where the configuration.yaml file is located) and the try again with the simple config setup and restart HASS:

vimar_platform:
  username: Amministratore
  password: *********
  host: 192.168.1.110

the integration should pick up the file on it's own.

alfienero commented 4 years ago

I've regenerated the certificate and installed it on all the machines I have including the one running HA. I also copied the crt in all the folders: HA root, vimar components, etc. and used the last config you suggested me.

Still not working I guess there is a problem in the certificate the webserver generates, I could try to ask vimar why certificates are not working 2020-06-08 16:29:02 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 16:29:02 ERROR (SyncWorker_1) [custom_components.vimar_platform.vimarlink] Other error occurred: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'192.168.1.110\', port=443): Max retries exceeded with url: /vimarbyweb/modules/system/user_login.php?sessionid=&username=Amministratore&password=*****&remember=0&op=login (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_server_certificate\', \'certificate verify failed\')])")))')) 2020-06-08 16:29:04 ERROR (MainThread) [custom_components.vimar_platform] Could not connect to Vimar Webserver 192.168.1.110 2020-06-08 16:29:04 ERROR (MainThread) [homeassistant.setup] Error during setup of component vimar_platform

h4de5 commented 4 years ago

Just updated the integration again. Could you test again. I still don't understand why i am not getting that error :/

alfienero commented 4 years ago

Just tried, same error :(

2020-06-08 17:02:28 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 17:02:29 ERROR (SyncWorker_4) [custom_components.vimar_platform.vimarlink] Other error occurred: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'192.168.1.110\', port=443): Max retries exceeded with url: /vimarbyweb/modules/system/user_login.php?sessionid=&username=Amministratore&password=***&remember=0&op=login (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_server_certificate\', \'certificate verify failed\')])")))')) 2020-06-08 17:02:30 ERROR (MainThread) [custom_components.vimar_platform] Could not connect to Vimar Webserver 192.168.1.110 2020-06-08 17:02:30 ERROR (MainThread) [homeassistant.setup] Error during setup of component vimar_platform

h4de5 commented 4 years ago

@alfienero this bugs me a lot. I have updated the repository - can you pull it again. and change the config to the following please:

vimar_platform:
  username: Amministratore
  password: *********
  host: 192.168.1.110
  certificate:

certificate should stay empty - this will force the to ignore any certificates errors. Please look out for messages like:

INFO (SyncWorker_11) [custom_components.vimar_platform.vimarlink] Request ignores ssl certificate

alfienero commented 4 years ago

You make it! I still have some issues but things evolved. Now in HA I have:

The following integrations and platforms could not be set up: vimar_platform.cover vimar_platform.light Please check your config.

Unknown objects in the log are 4 high energy load control switches and 2 temperatures measuring devices. Unfortunately since cover and lights platforms doesn't load I still don't have any new entitities.

In the log: 2020-06-08 22:04:42 INFO (MainThread) [custom_components.vimar_platform.vimarlink] Vimar link initialized 2020-06-08 22:04:42 INFO (SyncWorker_7) [custom_components.vimar_platform.vimarlink] Request ignores ssl certificate 2020-06-08 22:04:45 INFO (SyncWorker_7) [custom_components.vimar_platform.vimarlink] Vimar login successfull 2020-06-08 22:04:47 INFO (SyncWorker_8) [custom_components.vimar_platform.vimarlink] Request ignores ssl certificate 2020-06-08 22:04:48 INFO (SyncWorker_8) [custom_components.vimar_platform.vimarlink] getDevices started 2020-06-08 22:04:48 INFO (SyncWorker_8) [custom_components.vimar_platform.vimarlink] Request ignores ssl certificate 2020-06-08 22:04:48 INFO (SyncWorker_8) [custom_components.vimar_platform.vimarlink] getDevices ends 2020-06-08 22:04:49 WARNING (MainThread) [custom_components.vimar_platform] Unknown object returned from web server: CH_Carichi_3F / Forno 2020-06-08 22:04:49 WARNING (MainThread) [custom_components.vimar_platform] Unknown object returned from web server: CH_Carichi_3F / Lavastoviglie 2020-06-08 22:04:49 WARNING (MainThread) [custom_components.vimar_platform] Unknown object returned from web server: CH_Carichi_3F / Lavatrice 2020-06-08 22:04:49 WARNING (MainThread) [custom_components.vimar_platform] Unknown object returned from web server: CH_Carichi_3F / Piano cottura 2020-06-08 22:04:49 WARNING (MainThread) [custom_components.vimar_platform] Unknown object returned from web server: CH_HVAC_NoZonaNeutra / Termostato Camera 2020-06-08 22:04:49 WARNING (MainThread) [custom_components.vimar_platform] Unknown object returned from web server: CH_HVAC_NoZonaNeutra / Termostato Soggiorno 2020-06-08 22:04:50 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform vimar_platform.cover: Platform not found (cannot import name 'CoverEntity' from 'homeassistant.components.cover' (C:\Users\Gianluca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\homeassistant\components\cover__init.py)). 2020-06-08 22:04:50 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration homekit_controller: No module named '_crypt' 2020-06-08 22:04:51 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform vimar_platform.light: Platform not found (cannot import name 'LightEntity' from 'homeassistant.components.light' (C:\Users\Gianluca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\homeassistant\components\light\init__.py))

h4de5 commented 4 years ago

CoverEntity and LightEntity are only available on home-assistant > v0.110 i'll have a look how to make it more compatible with older versions.

h4de5 commented 4 years ago

@alfienero can you try again?

alfienero commented 4 years ago

@alfienero can you try again?

You are a genius!!! The platform now loads without any error and discovers dimmable lights and covers. I tried to control a cover and a dimmable light and is working!! The only strange thing is that is not discovering non-dimmable lights, but you made a big step forward with me!

h4de5 commented 4 years ago

@alfienero I updated some things in the meantime - please try again and let me know how it works in the new project: https://github.com/h4de5/home-assistant-vimar