oischinger / ha_vicare

Inofficial Home Assistant custom component for Viessmann ViCare API
61 stars 34 forks source link

Error during setup of component vicare #27

Closed doppelpunkt89 closed 4 years ago

doppelpunkt89 commented 4 years ago

Hello,

I am lost as I tried everything that I found myself on the internet. Since yesterday 1 pm I am getting this error in ha:

Protokolldetails ( ERROR ) Logger: homeassistant.setup Source: custom_components/vicare/init.py:68 First occurred: Invalid Date (1 occurrences) Last logged: 9:35:06

Error during setup of component vicare Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 174, in _async_setup_component component.setup, hass, processed_config # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/vicare/init.py", line 68, in setup vicare_api = HeatPump(conf[CONF_USERNAME], conf[CONF_PASSWORD], params) File "/usr/local/lib/python3.7/site-packages/PyViCare/PyViCareDevice.py", line 40, in init self.service = ViCareService(username, password, token_file, circuit) File "/usr/local/lib/python3.7/site-packages/PyViCare/PyViCareService.py", line 58, in init self._getInstallations() File "/usr/local/lib/python3.7/site-packages/PyViCare/PyViCareService.py", line 219, in _getInstallations self.id=self.installations["entities"][0]["properties"]["id"] KeyError: 'entities'

I already tried adding the custom_component (in this case) but it throws the same error as with the onboard component of vicare.

I am grateful for any help.

Thanks in advance and cheers

adorobis commented 4 years ago

It seems that it is either:

  1. general unavailability of the ViCare cloud service, as the mobile app does not work neither
  2. or as viessmann has informed, they will be closing their APIs this week, but in this case the question is if it also impacts the mobile app if you use the same account for it?
doppelpunkt89 commented 4 years ago

It seems that it is either:

  1. general unavailability of the ViCare cloud service, as the mobile app does not work neither
  2. or as viessmann has informed, they will be closing their APIs this week, but in this case the question is if it also impacts the mobile app if you use the same account for it?

My mobile app is still working

adorobis commented 4 years ago

My mobile app is still working

Have you been using this integration / API before or it has never worked for you?

doppelpunkt89 commented 4 years ago

It worked before and stopped yesterday. I first thought it might be connected to the installation of video2proxy (which also installed some python packages), but I cannot see how that may impact the docker container of ha.

adorobis commented 4 years ago

So here is the explanation: https://www.viessmann-community.com/t5/Experten-fragen/Q-amp-A-Viessmann-API/qaq-p/127660 Viessmann is putting limits on the usage of their API, it affects both official mobile app and all other integrations using the same account. Unfortunately they have not published what are the limits they have set.

geertmeersman commented 4 years ago

Could we change the polling interval in the vicare component? As in my case eg, I am only controlling my Viessmann through HA, so a slower polling would not really impact my usage.

doppelpunkt89 commented 4 years ago

So here is the explanation: https://www.viessmann-community.com/t5/Experten-fragen/Q-amp-A-Viessmann-API/qaq-p/127660 Viessmann is putting limits on the usage of their API, it affects both official mobile app and all other integrations using the same account. Unfortunately they have not published what are the limits they have set.

But wouldn’t than the component work at least from time to time? My feeling ist more that it is related to python...

My app is working totally fine, not matter how often I open it.

adorobis commented 4 years ago

Could we change the polling interval in the vicare component? As in my case eg, I am only controlling my Viessmann through HA, so a slower polling would not really impact my usage.

The standard scan_interval parameter is not implemented for vicare integration. Any idea where in the component code it should be introduced? I could play with it but would be faster if someone could give a hint where is the best place to put it :)

oischinger commented 4 years ago

I'm currently experimenting with the scan interval. I set it to 15 minutes. So far it seems to work. If. It keeps working until today evening I'll upload it here

geertmeersman commented 4 years ago

Thanks Hans!

adorobis commented 4 years ago

Excellent! I would be also interested to understand where in the integration code the polling interval can be controlled :)

adorobis commented 4 years ago

My limit has refreshed and I've put some logging for the component. It calls the API exactly every minute and after 23 minutes I've reached the limit of calls. Not sure if the daily or 15 minute limit.

oischinger commented 4 years ago

I have pushed this commit: https://github.com/oischinger/ha_vicare/commit/665b2aabd58d4c8c0efd05db4e633e8301b58806

This sets the update interval to 15 minutes. Worked for me within the last 8 hours but not yet 24 hours.

I guess something like this will have to be the hotfix for the Home Assistant integration. For an optimal solution we have to work on PyVicare to be able to fetch more than a single parameter via one HTTP GET.

oischinger commented 4 years ago

This fix will make it into 0.107 as a hotfix

geertmeersman commented 4 years ago

I will try it out and get back on it! Thanks for your swift solution Hans!

adorobis commented 4 years ago

Great, many thanks Hans! Already updated my system :) Now I just have to wait till tomorrow 5PM for my limit to reset... Will let you know my experience. Regarding improvements also some error handling would be helpful to inform HA that the API limit has been reached.

doppelpunkt89 commented 4 years ago

Many thanks for providing this fix, integration started successfully and is working as expected :)

Zixim commented 4 years ago

After reading @adorobis 's post on the (lousy) Viessmann forum, I'm wondering if anyone has actually tried doing an MQTT MITM (man in the middle) approach to intercept & digest the data ?

adorobis commented 4 years ago

After reading @adorobis 's post on the (lousy) Viessmann forum, I'm wondering if anyone has actually tried doing an MQTT MITM (man in the middle) approach to intercept & digest the data ?

Well, if if you read the discussion later on, it seems that it is not that easy as the device is using TLS encryption with certificate validation on client side. Most likely there is no way to interfere with this.

doppelpunkt89 commented 4 years ago

I will try it out and get back on it! Thanks for your swift solution Hans!

I would be very interested to learn more about your project to get the data via mqtt. is that actually already useable in home assistant?

Zixim commented 4 years ago

Well, if if you read the discussion later on, it seems that it is not that easy as the device is using TLS encryption with certificate validation on client side. Most likely there is no way to interfere with this.

To be honest, the navigation in the Viessmann forum hurts my brain. And I even understand basic German... Certificate validation will indeed take this option mostly off the table. Or at the very least, turn this MITM option into a huge hack, nothing reliable. dammit.

adorobis commented 4 years ago

I would be very interested to learn more about your project to get the data via mqtt. is that actually already useable in home assistant?

It is not using MQTT but a standard integration in HA. You can find more details about it in the official documentation: https://www.home-assistant.io/integrations/vicare/ It uses the Viessmann's cloud API.

Zixim commented 4 years ago

@doppelpunkt89 as @adorobis said, the Vicare: integration uses the Viessmann cloud API. If you activate this at this point in time, you will get your account banned after an hour or so. Better to wait untill HA goes to v0.107.0 , when the integration will rate_limit to please Viessmann.

geertmeersman commented 4 years ago

I have the vicare now running since yesterday evening with the scan_interval to 15 minutes and it works just fine! Thanks @oischinger :-) Let's hope they will not already cut the access this week and keep our access with this threshold until the developer portal will be fully operational

doppelpunkt89 commented 4 years ago

@doppelpunkt89 as @adorobis said, the Vicare: integration uses the Viessmann cloud API. If you activate this at this point in time, you will get your account banned after an hour or so. Better to wait untill HA goes to v0.107.0 , when the integration will rate_limit to please Viessmann.

But I already upgraded my custom component to the hot fix here, so everything is running fine for me since yesterday evening.

I would be very interested to learn more about your project to get the data via mqtt. is that actually already useable in home assistant?

It is not using MQTT but a standard integration in HA. You can find more details about it in the official documentation: https://www.home-assistant.io/integrations/vicare/ It uses the Viessmann's cloud API.

I am talking about @geertmeersman project which uses mqtt, I am not sure if we talk about the same things here. The standard vicare integration is running fine for me.

geertmeersman commented 4 years ago

Hi @doppelpunkt89 , I never used MQTT for vicare :-) I created an initial component, which was partly used by @oischinger for vicare, but this was never using MQTT :-) I am using the HA integration, created by Hans

doppelpunkt89 commented 4 years ago

Hi @doppelpunkt89 , I never used MQTT for vicare :-) I created an initial component, which was partly used by @oischinger for vicare, but this was never using MQTT :-) I am using the HA integration, created by Hans

Ok, than I got something mixed up here, never mind :) Thanks all for the support, from my side the issue can be closed :)

adorobis commented 4 years ago

Just been able to connect again, let's see how it goes. One observation: the limit has not been renewed after 24 hours but I was able to connect again after logging out and back in from the mobile app. Or maybe that was just pure coincidence... Anyway 15 minutes is just a bit too long to monitor burner status or supply temperature but let's see, maybe this could be addressed after they officially open up the API. For now many thanks for your great work Hans!

Zixim commented 4 years ago

same here, even though the 24H ban should have lapsed nearly 3 hours ago, my app's access was restored approx 1 h ago. I get the feeling they (VMNN) changed something. 🤷‍♂

doppelpunkt89 commented 4 years ago

Thanks all for your help and thanks for the quick fix :)