astrandb / miele

A modern integration for Miele devices in Home Assistant
MIT License
196 stars 29 forks source link

Get Actions for Miele devices #232

Open thetrebor opened 1 year ago

thetrebor commented 1 year ago

Feature request

So if i'm reading the docs properly you can pass in a device ID to the /actions and /programs GET apis and get a list of the device programs which you would need for making custom cards. It's frustratingly hard to get this data outside of HASS but i can't seem to nudge the python scripts in the plugin to let me just do an authenticated GET

curl -X 'GET' \ 'https://api.mcs3.miele.com/v1/devices/000176461151/programs' \ -H 'accept: application/json'

Would it be possible to add to the Services dropdown the ability to just do this GET on an ID so we can see the programs that are available on each device?

What version of the integration are you using?

miele-0-1-9

Anything in the logs that might be useful for us?

No response

Additional information

No response

thetrebor commented 1 year ago

i'm guessing we just need to add an option to set this entry to another endpoint like "programs":

        async with async_timeout.timeout(API_READ_TIMEOUT):
            res = await miele_api.request(
                "GET",
                f"/devices/{serial}/actions",
                agent_suffix=f"Miele for Home Assistant/{VERSION}",
            )

but there's so much configuration interdiction and constant swapping that im really not sure what the right spot is to inject the intent to talk to a different end point.

astrandb commented 1 year ago

If you look in the diagnostic download for your devices you can see if anything useful is reported on the /programs endpoint. Please test with the device in different states, such as power on, power off, delayed start enabled etc. Personally I don't have access to any devices with program features so I cannot do any testing myself. When I did my initial research I noted that the implementation in the API was not very consequent, to say the least. If you can find out what and when the API reports reliably, we can have a discussion how to use that information in the integration. There is no more documentation from Miele on this topic than what is published on their developer pages. I have asked...

thetrebor commented 1 year ago

Yeah it appears the programs end point just returns [] or a 500 error. The diagnostics similarly.

"programs": {
      "httpStatus": 500
    },
"programs": [],
{
        "appliance": "Microwave combination oven",
        "key": "stateProgramId",
        "raw": 0,
        "localized": ""
      },
      {
        "appliance": "Microwave combination oven",
        "key": "stateProgramType",
        "raw": 0,
        "localized": "Program"
      },
      {
        "appliance": "Microwave combination oven",
        "key": "stateProgramPhase",
        "raw": 0,
        "localized": ""
      },

and the logs are not helpful in that they don't display the ID used, just that one was used.

so is the only way to reverse engineer this to feed it program ids one at a time and see what it does?

thetrebor commented 1 year ago

just to follow up I have a ticket in with Miele about the chaotic API responses. they're responding, but slowly

ncd7 commented 1 year ago

Any news on this? I'd be interested in doing that for dishwasher programs. The Google Home integration does show all possible programs in a bullet list so it must be available. Not sure if it would be different for microwaves vs dishwashers. P.S. I have to say massive thank you to @astrandb because his integration is working SO reliably and really well!!

AlexCherrypi commented 1 year ago

I also would really appreciate this. I would love to be able to select the program, temperature, TwinDos setting, max spinning speed, starting time etc. for my Miele washing machine. I would love to completely ditch the miele app in favor of having everything accessible via homeassistant.