[SOLVED] REST API/NEST temperature item problem

After updating to 2.3 there is an issue with number items with units and the REST api

I have a knob widget to overide the nest thermostat set point just is case the wife is cold
I can change the set point via command in rules by doing:

House_NestTargetTemperature.sendCommand(19.0|°C)

The classic UI works too

REST API doesn’t :frowning_face:
and consequently HABpanel doesn’t either

The item is:

Number:Temperature House_NestTargetTemperature           "Target Temperature [%.1f °C]"  <temperature> (Thermostats)                                                                                              { channel="nest:thermostat:bca14bfe:dCd2AOytHIiKRTYPM00jxva1Q3Ryl-jm:set_point" }

For me, the REST API works well - it shows "state":"20.0 ℃" in the response for such items.

HABpanel doesn’t

I think this is the problem - HABPanel does not yet know how to handle numbers with dimensions - @henning it seems that we have totally missed that part when introducing the quantity types… @ysc Could you investigate how much change it would mean to HABPanel to support those new types? @henning do you have any advice of how the handling should be done best as you changed the Paper UI accordingly?

@chris Same question to you: What would it mean to bring support of Number items with dimension to HABmin?

@Kai

I must respectfully disagree.

A rest PUT request will update the item state. That works
A rest POST request (sendCommand) shows this in the log:

2018-06-01 21:50:36.038 [ome.event.ItemCommandEvent] - Item 'House_NestTargetTemperature' received command 21
2018-06-01 21:50:36.044 [vent.ItemStateChangedEvent] - House_NestTargetTemperature changed from 19.0 ℃ to 21.0 ℃

BUT it doesn’t get actioned by the binding and the thermostat stays at 19°C

Sending 21|°C as a command by the rest API results in this:

2018-06-01 21:53:06.624 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/House_NestTargetTemperature' with an invalid status value '21|°C'.

I’m not sure I understand what’s wrong, I have configured an item like above (without the channel link)

Number:Temperature TestQuantityType "Target Temperature [%.1f °C]"  <temperature>

And the HABPanel knob & slider sends the command without an unit which is understood, and the widgets still work?

22:52:53.984 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TestQuantityType' received command 21.2
22:52:54.101 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestQuantityType changed from 19.7 ℃ to 21.2 ℃
22:52:55.267 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TestQuantityType' received command 16.7
22:52:55.327 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestQuantityType changed from 21.2 ℃ to 16.7 ℃
22:53:00.257 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TestQuantityType' received command 22.7
22:53:00.360 [INFO ] [smarthome.event.ItemStateChangedEvent] - TestQuantityType changed from 16.7 ℃ to 22.7 ℃

image

If anything it’s unable to interpret %unit% in format patterns but that’s another story…

@ysc
The widgets work, they send a command to the item.
The problem is that the channel accepts a command in the new format 21|°C and not just 21

So this is an issue of the binding then and not of the REST API as you can see yourself from the log that it is correctly received through the REST API.

Sending 21|°C as a command by the rest API results in this

Clear, because this is not a valid format (only to be used in scripts).

That’s good news and quite some relief for me @ysc, thanks :slight_smile:

So if I understand the binding should still accept both 21 and 21|°C as command and not just exclusively 21|°C
Should I raise an issue on ESH?

Only 21 and 21 °C are valid commands, NOT 21|°C (as I said, this syntax is only used for variables in scripts).
If I see it right, you are using the Nest binding, which is in openhab2-addons, not ESH.

Apparently Paper UI knows how to send the command with the unit after a space if it has one.

HABPanel doesn’t do that but imho the binding should also accept a command without the unit.

Do you mean rules?

I can confirm that a POST request with 21°C works and the binding took the command

Yes, it is ok to send it without unit - the unit of the previous state is then simply kept.

Do you mean rules?

Yes, scripts are part of the rules (the stuff between “then” and “end”.

But that doesn’t work, at least for the nest binding

Coolio, learning terminology everyday, thanks

Issue of github: [NEST] Binding not accepting command without unit #3614

Temporarily solved with a proxy item:

rule "proxy in"
when
    Item House_NestTargetProxy received command
then
    House_NestTargetTemperature.sendCommand(receivedCommand.toString + "°C")
end

rule "proxy out"
when
    Item House_NestTargetTemperature changed
then
    House_NestTargetProxy.postUpdate(House_NestTargetTemperature.state as Number)
end

The binding can be modified so it assumes the unit is the same as the unit used for state updates. However when there are several items that each have their own unit the binding does not know about this.

For example:

Number:Temperature Thermostat_SP_C "Set Point [%.1f °C]" { channel="nest:thermostat:9fc91dad:PuNbMpQGIY3hk7Nf8qJh6secrx8nUoq_:set_point" }
Number:Temperature Thermostat_SP_F "Set Point [%.1f °F]" { channel="nest:thermostat:9fc91dad:PuNbMpQGIY3hk7Nf8qJh6secrx8nUoq_:set_point" }
Number:Temperature Thermostat_SP_K "Set Point [%.1f K]"  { channel="nest:thermostat:9fc91dad:PuNbMpQGIY3hk7Nf8qJh6secrx8nUoq_:set_point" }

I think such scenarios can only be fixed when HABPanel is modified to also add the unit or ESH infers the unit from the item.

Solved in last SNAPSHOT

openHAB 2.4.0 Build #1294

Thank you all

i have the same problem ,where can i find the fixed nest binding jar?

What problem are you encountering exactly?