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

OH3: number:temperature items not working with setpoint elements #765

Closed
bf8392 opened this issue Jan 6, 2021 · 16 comments · Fixed by openhab/openhab-core#2165
Closed
Labels
basic ui Basic UI bug Something isn't working

Comments

@bf8392
Copy link

bf8392 commented Jan 6, 2021

It appears that "number:temperature" items can't be contolled using setpoints in basicUI or MainUI. When the setpoint is clicked, no change is observed in the item. If the item is changed to "number", it can be controlled with setpoint in BasicUI.

https://community.openhab.org/t/solved-knx-binding-issues-with-thermostat-oh3/112724
https://community.openhab.org/t/openhab-3-setpoint/112801
https://community.openhab.org/t/oh3-set-temperature-on-homematic/112902/2

In the second thread, it's noted that number-with-setpoint doesn't work in MainUI. However, that may be a separate issue.

Please let me know if there's anything more I can do to help solve this problem.

Thanks!

original here: openhab/openhab-core#2067

@Wohlie
Copy link

Wohlie commented Jan 10, 2021

Hi, I'm pretty new in openHAB and I also run in these problems yesterday with openHAB 3.

I have the following two error:

HTTP error for Number:Temperature

With the following configuration:

  • Items:

    Number:Temperature    Livingroom_Heater_One_Temp_Desired_UI    "Heizkörperthermostat Soll-Temperatur [%.1f %unit%]"           <temperature>
    
  • Rules:

    rule "Heater in living room"
    when
        Item Livingroom_Heater_One_Temp_Desired_UI received update
    then
        logInfo("loggerName", "" + (Livingroom_Heater_One_Temp_Desired_UI.state as Number).floatValue)
    end
    
  • Sitemap:

    sitemap demo label="My home automation" {
        Frame label="Sample" {
            Setpoint item=Livingroom_Heater_One_Temp_Desired_UI minValue=16 maxValue=24 step=0.5
        }
    }
    

If I change the value of Livingroom_Heater_One_Temp_Desired_UI via the Basic UI the following HTTP error occurs:
image
The rule Heater in living room it not triggert.

Basic UI don't get updated

If I change the item type from Number:Temperature to Number and I change the value of Livingroom_Heater_One_Temp_Desired_UI via the Basic UI, the rule Heater in living room is triggered but the Basic UI is not refreshed and shows the old value. If I reload the Basic UI the correct value is shown.

@ghys ghys added basic ui Basic UI and removed main ui Main UI labels Jan 14, 2021
@jimtng
Copy link
Contributor

jimtng commented Jan 15, 2021

Also reported here openhab/openhab-addons#9659
The issue is not related to the binding. The issue is related to basicui.

How to reproduce:
test.items file

Number TestSetPointNumber
Number:Temperature TestSetPointTemp

Sitemap:

sitemap default label="Home Control Panel"
{
	Frame label="Home Control" {
		Setpoint item=TestSetPointNumber 
		Setpoint item=TestSetPointTemp
	}
}

The Setpoint for TestSetPointNumber will work but the setpoint for TestSetPointTemp will not.
This was previously working on OH 2.5

@chris922
Copy link

This sounds like the same issue that I reported (in the probably wrong) openHAB core repository -> openhab/openhab-core#2091

Do you also use the openHAB app on your mobile and can you check if changing there works and if you then can afterwards also change via Web BasicUI? If this is the case both is the same issue and I would close my ticket as it is then in the wrong repository.

@billfor
Copy link

billfor commented Jan 19, 2021

Verified that you can control Number:Temperature items with the Android apk. It is the basicUI that has the issue. I actually have had it work in basicUI, but very very sporadically.

This is very easy to repro just create:
Number:Temperature TestSetpoint "Set Temperature [%.1f %unit%]"
//Number TestSetpoint "Set Temperature [%.1f]"

Without the Unit it works it will update in the basicUI, but with the unit it will not.

One other thing I noticed is that if you write a rule to catch the change, it doesn't work. Not sure if that is a clue (or maybe it's not supposed to work). e.g I never see the output for this:

rule "TestSetpoint"
when
Item TestSetpoint changed
then
logInfo("org.openhab","Value of the setpoint: "+ TestSetpoint.state)
end

@JensHoRi
Copy link

Same problem here. I can exclude as reasons:

  • Persistence (System running since days, the issue cam up after some time in running system without restore due to persistence)
  • Failures in Sitemaps and Items (Same as OH 2.5 all running fine, only setpoints only after usage of App

Just a deeper Analysis:
a) No Restart within two days, fresh opened Broswer:
Command per method post with 19.5 %unit% gaves a failure.
b) Using App, then use Browser again: Command method get is successfull.

So the Basic UI working with post before App is used, after usage of App it uses get and all fine.

Because all other Items in Web UI Using GET (just checked), this seems to be the reason, there is a bug in Basic UI causes setpoint after open the sitemap to cause PUT instead of get!

@andrewfg
Copy link

andrewfg commented Jan 29, 2021

I think @JensHoRi is wrong about the GET/POST and the App -- see my post on the community..

https://community.openhab.org/t/crazy-bevavior-in-basic-ui-oh3/114927/16?u=andrewfg

@andrewfg
Copy link

andrewfg commented Jan 29, 2021

I did a wildcard search in the BasicUI code for the string %unit% (which is the root cause of the problem). And it leads me to guess that the issue could somehow be related to how the SetpointRenderer.java class generates the HTML code for the web page. I am guessing that getUnitForWidget(w) returns a bad/empty/null value. EDIT: a null value I think

image

@andrewfg
Copy link

andrewfg commented Jan 29, 2021

PS the work around is to explicitly include a label tag in the sitemap script where the label has the correct unit formatting string..

// this fails
Setpoint  item=Front_Bedroom_Radiator_Target_Temperature minValue=15 maxValue=27 step=1 
...
// this succeeds
Setpoint  item=Front_Bedroom_Radiator_Target_Temperature minValue=15 maxValue=27 step=1 label="Aardvark [%.1f °C]"

@andrewfg
Copy link

By the way, I now understand why the App may solve the issue for @JensHoRi -- the SetpointRenderer.java code is running on the server to generate HTML for the web pages; so using the App may cause this code to be initialised with a non null string to replace the %unit% placeholder..

@apella12
Copy link

I believe I had the same issue. I used Selection as a workaround.
https://community.openhab.org/t/sitemap-setpoint-formatting-in-oh3/110300

@JensHoRi
Copy link

I tried to search the way back from function to function. I'm no developer, and really not sure, but looks like at the end there is a reference to some system.units. So maybe °C not defined in metric system for temperature or something like that. :-( I'm out, This need the know how of some of our great developers doing so amazing work

@chris922
Copy link

The issue seems to be in the openhab/openhab-core repository:

                String unit = getUnitFromLabel(w.getLabel());
                if (!UnitUtils.UNIT_PLACEHOLDER.equals(unit)) {
                    return unit;
                }

                return ((NumberItem) item).getUnitSymbol();

(see here)

If there is no label defined for the Setpoint widget getUnitForLabel(..) will return null and because null is not equal to the placeholder (%unit%) null will be returned. return ((NumberItem) item).getUnitSymbol(); which gets the unit symbol from the item and not the Setpoint widget will not be invoked.

I will try to make a PR that fixes this issue.

@andrewfg
Copy link

@chris922 many thanks for this, much appreciated.

@JensHoRi
Copy link

JensHoRi commented Jan 30, 2021

It should reply the standard placeholder for unit instead, right?
So if null it should
return UnitUtils.UNIT_PLACEHOLDER should be right

@chris922
Copy link

I just raised the PR openhab/openhab-core#2165

Imho the UNIT_PLACEHOLDER should not be returned, because than we stay with the issue that %unit% will be used in the requests when the value should be changed.

I added a fallback to the unit-symbol of the item in case no label for a widget was defined. As outlined in my PR I don't know how to verify this with my local openHAB instance.. if someone gives me more information how I can use this version in my openHAB instance I would try the fix there as well.

@valpackett
Copy link

valpackett commented Jul 25, 2021

This is still an issue in MainUI?? e.g. with controlling yeelights via the miio binding: it generates temperature and time setpoints and the UI is useless:

Screenshot 2021-07-26 at 00-14-51 openHAB
Screenshot 2021-07-26 at 00-14-41 openHAB

(workaround: metadata can be attached via UI too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
basic ui Basic UI bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants