Skip to content

pyHPSU and openHAB 3.0 #34

@martinbischofff

Description

@martinbischofff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions