Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyHPSU and openHAB 3.0 #34

Open
martinbischofff opened this issue Feb 6, 2021 · 0 comments
Open

pyHPSU and openHAB 3.0 #34

martinbischofff opened this issue Feb 6, 2021 · 0 comments

Comments

@martinbischofff
Copy link

martinbischofff commented Feb 6, 2021

Hi all.

I'm just migrating to OH 3.0 and found the following issue: When trying to send values to openHAB the log files fills with errors like
2021-02-06 21:16:38.810 [ERROR] [rg.apache.cxf.jaxrs.utils.JAXRSUtils] - No message body reader has been found for class java.lang.String, ContentType: application/octet-stream

Appearently this is caused by a missing header. Changing openhab.py like this seems to resolve that issue:

        url = "http://%s:%s/rest/items/%s%s/state" % (self.openhabhost, str(self.openhabport), self.openhabitemprefix, item)
        try:
            headers = {"Content-Type": "text/plain"}
            r = requests.put(url, data=str(value), headers=headers)
        except requests.exceptions.RequestException as e:
            rc = "ko"
            self.hpsu.printd("exception", "Error " + str(e.code) + ": " + str(e.reason))

A quick test didn't show any problems with openHAB 2.5, so this might work for both versions.

Anyone who can verify this?

Regards
Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant