coolweb / org.openhab.binding.mystromecopower

Openhab binding for MyStrom Eco Power Adapter
1 stars 2 forks source link

too many requests #9

Open napoleonmm83 opened 8 years ago

napoleonmm83 commented 8 years ago

Hi Coolweb today i get this amil from Mystrom, did you think you can fix this,

Dear Customers

We experience on our platform to many requests for data. In order to keep mystrom.ch healthy and alive we ask you to change your scripts/queries.

Please do the following

  1. Change your scripts such that (if possible) you use one request https://mystrom.ch/mobile/devices to query all devices using rather than repeating https://mystrom.ch/mobile/device for each device
  2. Do not send https://mystrom.ch/mobile/device request multiple times
  3. Do not send more often than every 60 seconds
  4. If you have to use https://mystrom.ch/mobile/device then please add minimal=true parameter

Please apply the changes within 7 days. Please inform us when done.

Best Regards,

Tom Kienle

coolweb commented 8 years ago

Hello, I received the same email yesterday. The first thing you could do on your side is to change the refresh of the binding with at least 60000. I will fix the binding but within 7 days it's too short, I send an email to mystrom to advise him about this delay problem...

Le dim. 14 févr. 2016 21:34, napoleonmm83 notifications@github.com a écrit :

Hi Coolweb today i get this amil from Mystrom, did you think you can fix this,

Dear Customers

We experience on our platform to many requests for data. In order to keep mystrom.ch healthy and alive we ask you to change your scripts/queries.

Please do the following

  1. Change your scripts such that (if possible) you use one request https://mystrom.ch/mobile/devices to query all devices using rather than repeating https://mystrom.ch/mobile/device for each device
  2. Do not send https://mystrom.ch/mobile/device request multiple times
  3. Do not send more often than every 60 seconds
  4. If you have to use https://mystrom.ch/mobile/device then please add minimal=true parameter

Please apply the changes within 7 days. Please inform us when done.

Best Regards,

Tom Kienle

— Reply to this email directly or view it on GitHub https://github.com/coolweb/org.openhab.binding.mystromecopower/issues/9.

lakermann commented 8 years ago

Thank you for the answer, received the same email yesterday.

napoleonmm83 commented 8 years ago

how can i change the refresh time with openhab.cfg ?

lakermann commented 8 years ago

Just found the code sequence in MyStromEcoPowerBinding.java

Default interval is 60000ms / 60s:

**  
* the refresh interval which is used to poll values from the MyStromEcoPower 
* server (optional, defaults to 60000ms) 
*/ 
private long refreshInterval = 60000; 

Set custom interval:

// to override the default refresh interval one has to add a  
// parameter to openhab.cfg like <bindingName>:refresh=<intervalInMs> 
String refreshIntervalString = (String) config.get("refresh"); 

so try to set refresh parameter in openhab.cfg (value should not be lower than 60000):

mystromecopower:refresh=<intervall in ms>
coolweb commented 8 years ago

@napoleonmm83 , @lakermann sorry for the mistake, the default refresh interval is 60 sec, so nothing to change. I do a new release with a fix, could you try with it and say me if all is working? https://github.com/coolweb/org.openhab.binding.mystromecopower/releases/tag/V1.8.1 I'll ask to mystrom if it is ok with this version...

napoleonmm83 commented 8 years ago

I use now the new version from today, hope is better now.

napoleonmm83 commented 8 years ago

Now i get this in Log, this was not before.

2016-02-15 20:27:47.376 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - Devices discovery sucessfull, found '10' devices 2016-02-15 20:28:47.379 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - get devices... 2016-02-15 20:28:47.746 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - Devices discovery sucessfull, found '10' devices 2016-02-15 20:29:47.749 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - get devices... 2016-02-15 20:29:48.018 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - Devices discovery sucessfull, found '10' devices 2016-02-15 20:30:42.123 [INFO ] [del.script.z-wave motion ligth] - light on 2016-02-15 20:30:48.021 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - get devices... 2016-02-15 20:30:48.244 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - Devices discovery sucessfull, found '10' devices 2016-02-15 20:31:11.866 [INFO ] [o.i.r.i.resources.ItemResource] - Received HTTP GET request at 'items/Weather' for the unknown item 'Weather'. 2016-02-15 20:31:25.808 [INFO ] [del.script.z-wave motion ligth] - light off 2016-02-15 20:31:48.246 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - get devices... 2016-02-15 20:31:48.504 [INFO ] [o.b.m.i.MyStromEcoPowerBinding] - Devices discovery sucessfull, found '10' devices

coolweb commented 8 years ago

@napoleonmm83 ok, just reuse of some code and so more logs... sorry. Could you redownload the fix and test again?

lakermann commented 8 years ago

@coolweb my logs :

org.openhab.binding.mystromecopower_0.0.2.jar:

08:15:05.589 [DEBUG] [penhab.binding.mystromecopower:34   ] - MyStromEcoPower binding has been started.
08:15:05.714 [INFO ] [penhab.binding.mystromecopower:266  ] - Do mystrom discovery
08:15:05.714 [DEBUG] [penhab.binding.mystromecopower:57   ] - Do login for user '<username>'
08:15:05.745 [DEBUG] [penhab.binding.mystromecopower:117  ] - execute() method is called!
08:15:06.421 [DEBUG] [penhab.binding.mystromecopower:74   ] - Logon successfull
08:15:06.421 [INFO ] [penhab.binding.mystromecopower:103  ] - get devices...
08:15:06.515 [INFO ] [penhab.binding.mystromecopower:131  ] - Devices discovery sucessfull, found '2' devices
08:15:06.515 [INFO ] [penhab.binding.mystromecopower:280  ] - Mystrom device name: '<deviceName1>', mystrom device id:'<deviceId1>'
08:15:06.515 [INFO ] [penhab.binding.mystromecopower:280  ] - Mystrom device name: '<deviceName2>', mystrom device id:'<deviceId2>'
08:16:05.762 [DEBUG] [penhab.binding.mystromecopower:117  ] - execute() method is called!
08:16:05.762 [DEBUG] [penhab.binding.mystromecopower:125  ] - Mystrom eco power switch '<switch1>' state will be updated
08:16:05.762 [DEBUG] [penhab.binding.mystromecopower:155  ] - get device info...
08:16:07.025 [DEBUG] [penhab.binding.mystromecopower:125  ] - Mystrom eco power switch '<switch2>' state will be updated
08:16:07.025 [DEBUG] [penhab.binding.mystromecopower:155  ] - get device info...
08:17:07.111 [DEBUG] [penhab.binding.mystromecopower:117  ] - execute() method is called!
08:17:07.111 [DEBUG] [penhab.binding.mystromecopower:125  ] - Mystrom eco power switch '<switch1>' state will be updated
08:17:07.111 [DEBUG] [penhab.binding.mystromecopower:155  ] - get device info...
08:17:07.345 [DEBUG] [penhab.binding.mystromecopower:125  ] - Mystrom eco power switch '<switch2>' state will be updated
08:17:07.345 [DEBUG] [penhab.binding.mystromecopower:155  ] - get device info...

org.openhab.binding.mystromecopower-1.8.1.jar

08:28:35.087 [DEBUG] [b.m.i.MyStromEcoPowerActivator:34   ] - MyStromEcoPower binding has been started.
08:28:35.259 [INFO ] [o.b.m.i.MyStromEcoPowerBinding:371  ] - Do mystrom discovery
08:28:35.259 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:69   ] - Do login for user '<username>'
08:28:35.259 [INFO ] [.service.AbstractActiveService:169  ] - MyStromEcoPower Refresh Service has been started
08:28:35.259 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:142  ] - execute() method is called!
08:28:36.023 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:86   ] - Logon successfull
08:28:36.023 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:279  ] - get all devices state
08:28:36.117 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:312  ] - Devices discovery sucessfull, found '2' devices
08:28:36.117 [INFO ] [o.b.m.i.MyStromEcoPowerBinding:389  ] - Mystrom device name: '<deviceName1>', mystrom device id:'<deviceId1>'
08:28:36.117 [INFO ] [o.b.m.i.MyStromEcoPowerBinding:389  ] - Mystrom device name: '<deviceName2>', mystrom device id:'<deviceId2>'
08:29:35.249 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:142  ] - execute() method is called!
08:29:35.249 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:279  ] - get all devices state
08:29:43.697 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:312  ] - Devices discovery sucessfull, found '2' devices
08:29:43.697 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:152  ] - Mystrom eco power switch '<switch1>' state will be updated
08:29:43.697 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:152  ] - Mystrom eco power switch '<switch2>' state will be updated
08:30:43.703 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:142  ] - execute() method is called!
08:30:43.703 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:279  ] - get all devices state
08:30:44.113 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:312  ] - Devices discovery sucessfull, found '2' devices
08:30:44.113 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:152  ] - Mystrom eco power switch '<switch1>' state will be updated
08:30:44.113 [DEBUG] [o.b.m.i.MyStromEcoPowerBinding:152  ] - Mystrom eco power switch '<switch2>' state will be updated

Now it looks like you are querying all devices rather than repeating for each device.

coolweb commented 8 years ago

@lakermann Yes I query once for all devices, this is what MyStrom asked. So if you have 10 devices defined once as number, once as switch and once as string, in place of 30 queries you have one query.

@napoleonmm83 @lakermann I received feedback from MyStrom and with this fixed it's ok. So I'll do a pull request on the openhab repository.

Thanks for your help.

lakermann commented 8 years ago

@coolweb Thank you for the feedback (I actually wanted to say that my test was sucessful). Maybe it would be good to check the input parameter refresh in MyStromEcoPowerBinding.java to ensure the value isn't lower than 60000 (and if it is, then set it to 60000 and make a log entry).

// to override the default refresh interval one has to add a  
// parameter to openhab.cfg like <bindingName>:refresh=<intervalInMs> 
String refreshIntervalString = (String) config.get("refresh");