I just had to modify the RESTtful sensor, one of the API’s I tried to use required a user-agent to be specified, but the current RESTful sensor does not provide a user-agent. Supplying headers={‘User-agent’: ‘Home Assistant’} to the request was enough to make it work in my altered version.
But maybe we need to set a default user-agent or expose the headers so we can supply them ourselves in case other RESTful services need other headers to be present ?
It was this API that required it: https://haveibeenpwned.com/api/v2 i’m currently using it in a RESTful sensor to display the number of breaches my email accounts have had and i’m gonna add automations to notify when the number changes.
There is another problem, this service only allows X requests per X seconds. If you specify more then one sensor like this (for multiple email addresses) you have no control on HASS startup over this. A delay option might solves this. Currently I specified different scan_interval's for each of my email accounts so the problem only happens mostly when Home Assistant starts and due to difference in scan_intervals there is less potential that 2 RSTful sensors do the request against the same service quickly in succession (so that one of the requests fails).
i could not get it to work so i’m making a seperate component for this now where you just supply a list of email addresses in the configuration. However i do still think that the headers should be exposed and configureable from the configuration
I don’t really need it anymore myselve as i’m doing my own requests now in the email breaches component but i guess sooner or later somebody is goana need it
for reference, in case anyone wanted to use the “have i been pwned” service as well. I create a seperate component for it where you can just specify your email accounts in your configuration
I think this feature request could be marked as resolved/implemented. I follow the Home Assistant repository on GitHub and support for headers was recently added to the RESTful command and switch. The docs for the RESTful command reflect this, but the docs for the RESTful switch seem to need updating still.
The RESTful sensor and binary sensor received support for headers back in September/October 2016. The only RESTful component missing out belongs to the notify platform.