oklona / Miele-MQTT

A very simple script to read data from Miele@home cloud services, and publish using Mosquitto MQTT
21 stars 10 forks source link

Addition of PUT actions #2

Closed ChutneyMary closed 4 years ago

ChutneyMary commented 5 years ago

Miele have advised with effect 19 September -

19 September 2018 Maintenance release of Miele 3rd party API (OpenBeta)

Current version is V1.0.1

Changes

Is there a possibility to incorporate PUT actions through MQTT?

oklona commented 5 years ago

Hmm... Yes, that should be possible. I need to look through the updates to the API :-)

oklona commented 5 years ago

Need to rewrite much of the script for this to work, as the script now would need to be left running, to listen for incoming commands. This could naturally be a separate script, derived from the first one, using the same config-file. -Or it could be the same script, that could take a parameter to be in "listen" mode.

ChutneyMary commented 5 years ago

Is there scope to decide what input format will be used to receive incoming commands? I assume MQTT would be obvious...but if there's scope to use POST commands, that would also work for many home automation systems.

ChutneyMary commented 5 years ago

Hi oklona. Any progress with PUT actions for the API?

oklona commented 5 years ago

Hello. I will be looking at this now. As mentioned, I will need to rewrite quite a bit, as the script is currently single-threaded, without any looping. Now it will need to be running "permanently" to listen for incoming actions, and then execute the querying of devices regularly.

ChutneyMary commented 5 years ago

I forward the following information from Miele. This suggests new credentials are required to continue using the API

"Dear users of the Miele 3rd Party API,

Today ends the beta phase of the Miele 3rd Party API. Tomorrow we will officially release version 1.0 of the API. We would like to thank all participants of the beta-phase and thank you for the received feedback. Not all requests and suggestions could be directly considered, but we promise to make changes and improvements all the time and are always happy to receive your feedback and suggestions (which are included in our backlog).

What's new (changes)? First, we have adjusted our terms of use. This was necessary for commercial users to use the API. We also made small adjustments to individual endpoints, for example SpinningSpeed ​​is now localized. We have also increased the number of possible actions. Before an action is executed on a device, a GET action can be used to check which actions are available.

What's next? We will change the registration process. This new procedure eliminates the need to request credentials by e-mail. Customer ID and customer password can be created directly on developer.miele.com. However, this change requires all API users to create new credentials. The old credentials expire 30 days after the launch date of the new registration. We will inform you shortly by e-mail about the date of the change.

Thanks again for participating in the beta program.

Best regards, Your Miele 3rd Party API Team"

oklona commented 5 years ago

Yes, I saw that. However, as they say, the old credentials expire 30 days after they make it possible to get new credentials. -So the old ones will still work for at least a month.

For incorporating actions, I have a few options:

As of now, I lean towards the first option, as that will probably be the fastest way to get something ready, and it could still be contained within one script.

christianTF commented 5 years ago

Hi, I‘m Christian, the developer of the MQTT->Loxone Gateway.

Some of my plugin’s users use your Miele script to talk to the MQTT broker.

For my users, currently I prefer option 1.

Regarding PHP: The best implemented PHP Lib mosquitto-php needs mosquitto-devel installed, and configured in php.ini (not nice). I have https://github.com/techdada/phpMQTT (forked from https://github.com/bluerhinos/phpMQTT) in my watchlist, but not tried yet. It php-natively implements the mqtt protocol.

Python would be comparable easily to install, but C no novice user might get managed.

Regards, Christian

oklona commented 5 years ago

Agreed, so at least for now, that is the path I will be following.

oklona commented 4 years ago

I have now made some updates, and implemented the bluerhinos stack into the script. It is now possible to send commands to the appliances. In order to verify responses from the Miele API after posting your commands, you can uncomment the var_dump statement in line 289.

Since the script now needs to listen for MQTT data, it runs continuously, and checks data from Miele every 30 seconds.

I am considering adding an oAuth token refresh every week, or something like that, by adding a timestamp for the token into the config file, and trigger a refresh based upon that.

I am also considering command switches for just running once, publish data, and exit (will naturally make issuing commands impossible), and also possibly a switch to trigger json output, as someone requested this through another channel.