Update of an Number:Temperature item fails in python

  • Platform information:
    • Hardware:Raspberry B3
    • OS:Raspbian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: openhabian 2.3 stable
  • Issue of the topic: I want to update a Number:Temperature item raises error in python
  • Please post configurations (if applicable):
    • Items configuration related to the issue

Number: Temperature BoilerTemperature “BoilerTemperatur [%.1f °C]”

  • Sitemap configuration related to the issue
    not relevant
  • Rules code related to the issue

#openHAB Verbindung
base_url = ‘http://192.168.xxx.xx:8080/rest
openhab = openHAB(base_url)

#fetch WUG_TempAVGDitem
BoilerTemperature = openhab.get_item(‘BoilerTemperature’)


  • Services configuration related to the issue

  • If logs where generated please post these here using code fences:

    Traceback (most recent call last):
    File “./xxxx.py”, line 33, in
    File “/usr/local/lib/python3.5/dist-packages/openhab/items.py”, line 128, in command
    File “/usr/local/lib/python3.5/dist-packages/openhab/items.py”, line 88, in _validate_value
    raise ValueError()

Don’t know what is wrong - if I change the item type to Number it works.
Thanks for support

Is the item bound? I mean is there a binding link or config?

No - there is no binding to the item. I just want to update via python.

I am a bit baffled inspite of the full description of your system, as it is not clear to me what actually is not working.
Is your python generating errors? or is that diligently sending the data but is openHab not understanding it…unless you “make it a numbertype” (where? in Python? in OpenHab?)

You probably have your reasons not to make it a number, but sometimes if you send a number as a string via MQTT and it has a leading or trailing space…openhab may have difficulty changing it back to a number.
Could it be that the value you are getting in- and sending from python has leading/trailing spaces?

Thanks Kees!
Python is sending the error message - if I use “just” a Number-type item (in openHAB) it works perfectly.
The Number:Temperature-type item (in openHAB) are not accepted in python or I didn’t find the right format to update the item. As from the error message it seems to be some validation error.

1 Like

Ah ok now I understand. You were sending data from openhab to python. Sorry for my confusion.

Would pulling it in via the REST API maybe work…if it is really important to have it as a string? Though Maybe that gives the same problem.

Sorry, for the confusion:
I want to update a Number:Temperature-type item from python via REST API - which is not working.
If you “get” the item in python from openhab (BoilerTemperature = openhab.get_item(‘BoilerTemperature’)) everything is okay and works perfect. I am looking for the right syntax to send the information back - if this is working at all.
@sim0nx: Georges, since you have written the openhab module could you please have a look. Maybe the Number:Temperature items are not validated correctly. If one updates the item via bash/REST API it works fine. Thanks for a hint.

1 Like