esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
411 stars 26 forks source link

Authenticated http Request to Shelly 1 Plus #2649

Open Sniptzler opened 5 months ago

Sniptzler commented 5 months ago

Describe the problem you have/What new integration you would like

I want to directly communicate with a Shelly Plus 1 via an http request with authentication enabled. For that to work i need a way to authenticate via digest wich is currently not supported by the http_request component.

Please describe your use case for this integration and alternatives you've tried:

I thought about constructing the authentication message myself but couldn't find a way to encode in sha256. A way of doing that would resolve my issue. Is there a way i have overlooked?

Additional context

The authentication process is described here.

nagyrobi commented 5 months ago

Try like this: https://esphome.io/cookbook/http_request_sensor#id2 Not guaranteed to work though, as the Shelly has its own webserver implementation, but who knows...

Sniptzler commented 5 months ago

I have seen this but to my understanding this always sends the same authorization header in the http request which works in the case of the esphome webserver but not normaly because shelly includes the

nonce: number, random or pseudo-random number to prevent replay attacks, taken from the error message. Required

To my understanding this results in an always changing hash value. But this is only my limited understanding. Correct me if I'm wrong.

nagyrobi commented 5 months ago

You're understanding correctly.

Sniptzler commented 5 months ago

Do you think it is possible to get the SHA256 algorythm to work in esphome on the esp8266? Mybe there are even other use cases for this?

nagyrobi commented 5 months ago

https://wokwi.com/projects/328395940175020627