Philips Airfryer & NutriU Integration (Alexa only)?

HA can ping airfryer and all sensor is created but are always empty

“Allow All Imports” in pyscript config needs to be checked (I’ll add that to the “documentation”), but this should throw an error in the log.
image
At the moment I can’t think of a problem where there is no error in the log, but also pyscript.airfryer_status doesn’t show “offline”.

pyscript configuration is the same… but al values is 0

i try to uninstall and reinstall pyscript and now i have some error:

2024-02-03 17:32:50.603 ERROR (MainThread) [custom_components.pyscript.file.airfryer.airfryer_sensors_update] Exception in <file.airfryer.airfryer_sensors_update> line 74:
        response = get_status(pyscript.airfryer_token)
                              ^
Error: Invalid base64-encoded string: number of data characters (21) cannot be 1 more than a multiple of 4

That’s because the state of the airfryer_token is “m”. That shouldn’t be there. Just click on the blue entity name, then “set state” opens where you can empty the state again. That should remove that error.
Are you using the correct endpoint (command_url)? It should be the one with “airfryer” in your case.

If my last message didn’t help, add the two new lines to airfryer_sensors_update

    if response[0] == "offline":
        log.error(response[1])

like that

@service
@time_trigger("startup", "period(now, "+update_interval+")")
def airfryer_sensors_update():
    response = get_status(pyscript.airfryer_token)
    if response[0] == "token":
        pyscript.airfryer_token = response[1]
        response = get_status(pyscript.airfryer_token)
        log.info("Airfryer: New Token generated")
    if response[0] == "offline":
        log.error(response[1])
    set_entities(response)

That way there should be new error messages in the log giving more info.

nothing change always same error on line 74

pyscript.airfryer_token is empty but same error

Now I was able replicated the error: It happens when the letter count of client_id and/or client_secret is wrong. You should check that you entered them correctly.

1 charatect was lost, now i don’t have error and the token is correctly generated, but all other values dont change

I already wrote the next debugging step above: Philips Airfryer & NutriU Integration (Alexa only)? - #49 by nicohirsch
Please don’t let me do everything for you. I’d rather use that time to make the script better for everyone.

Today I reworked the code quite a bit:

  • Reordered and added some new settings
  • Listed all the available services
  • Created descriptions and selectors for all services
  • Added new services (Adjust Time, Adjust Temp)
  • Optimized existing services
  • Optimized the frontend card to be usable if you don’t have Airspeed or Temp Probe
  • Additionally I added the guide how to get the secrets to the Gist

Since English is obviously not my native language, I would be happy if you let me know if you find anything wrong or misleading in the descriptions (preferably by DM to avoid further spamming the thread here)

I think I fixed the crashing issue by making sure, that no two services are running in parallel. In the past it was possible to call a service like “airfryer_start_cooking” while in the background the sensors get updated. Now, depending on who’s first, either your service_call (for example “airfryer_start_cooking”) gets delayed a little bit or the sensor update is skipped once.

I also moved the code from Github Gists to a new repository:

1 Like

For everybody who is trying to get their API Key and can’t succeed.

I use a debugging Proxy - like Charles - to record all the traffic between the NutriU App on my phone and the servers. You need to turn on SSL proxy and force-quite the app before, so that it’s logging in again to the server. During this process the app get the API Key for your Airfryer.

As I mentioned earlier in a post, I tried to mimic the login process in order to receive the API key outside of the app, but I got stuck there. Maybe someone has the time to further dig into it.

My integration with Airfryer HD9285 stopped working in HA so I started investigating. I wasn’t able to call the endpoints from Postman using valid Authorization header so I turned on the VM to double check if my client id/secret are valid. I discovered that my client secret has changed! I am suspecting that this might have happened when I enabled remote control in the app on my phone. There are also some other changes in the database. So keep an eye for this, maybe you will confirm when can the secret change.

After updating the secret in HA it works again :slight_smile:

For my HD9285 I needed this configuration

pyscript:
  allow_all_imports: true
  apps:
    airfryer:
      airfryer_ip: "192.168.1.78"
      client_id: "XXXXXXXXXXXXXXXXXXX"
      client_secret: "XXXXXXXXXXXXXXXXXXX"
      time_total: "time"
      time_remaining: "cur_time"
      replace_timestamp: True
1 Like

I wrote a cloud implementation for nutriu for ioBroker maybe someone can test it.
I have still some issue with the mqtt cloud connection
But I can easily read client id and secret maybe I can join the local connection

i have air fryer HD928X and with your configuration don’t work, I have a client id and client secret, the integration generate a token but no value from sensor, if I try with a curl request using token generator for the integration I receive 401 response.

Thanks for the warning! I can’t test it at the moment, but I have at least written a note in the “guide”.
I have marked the sensors as working for the model number in the README. If you have the possibility to analyze the traffic of the app, then we can also check the service_calls (what does the app send to the airfryer when you start the connection; setup, start, pause, stop cooking). I think at least a few of them don’t work the same way as on my model.

That looks great! I don’t use ioBroker and don’t know if I’ll get around to setting up a test instance yet. But if you have any questions about the local connection, feel free to send me a DM - maybe I can help.

401 means “unauthorized”. So I think there’s a problem with you client_id / client_secret. You should check them again - either there’s a typo or maybe they have changed for you too.