hektiker1983 / openhab

Automatically exported from code.google.com/p/openhab
0 stars 0 forks source link

greent slider read-only #376

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I've programmed a small web server for my arduino that controls some LED 
strips by using the PWM outputs of an arduino Pro mini. For example I can set a 
new PWM value by submitting the URL 
http://192.168.178.1/analogWrite?pin=3&value=100. This works perfectly with the 
classic GUI. Turn ON, OFF, INCREASE and DECREASE are working as expected. The 
greent UI always shows the correct values, but if a pull the slider in any 
direction, it immediatly flip back in the old position and the value is 
unchanged.

I'm using openhab 1.2 with ubuntu server 13.04. For accessing the greent UI I'm 
using Chromium Version 28.0.1500.52.

This is my item definition:
Dimmer licht_schrank    "Dimmer [%d %%]"      <slider> 

This is my rules file:
var Number percent = 0

rule "Licht Schrank"
    when
        Item licht_schrank received command
    then
        if(licht_schrank.state instanceof DecimalType) percent = licht_schrank.state as DecimalType 

        if(receivedCommand==ON) percent = 100
        if(receivedCommand==OFF) percent = 0
        if(receivedCommand==INCREASE) percent = percent + 5
        if(receivedCommand==DECREASE) percent = percent - 5

        if(percent<0)   percent = 0
        if(percent>100) percent = 100
        postUpdate(licht_schrank, percent);
        postUpdate(licht_schrank, sendHttpPostRequest("http://192.168.178.1/analogWrite?pin=3&value=" + percent));
end

Original issue reported on code.google.com by stefanm4...@googlemail.com on 12 Jul 2013 at 6:41

GoogleCodeExporter commented 8 years ago
Hi again, I've corrected the last line before end so now my rules file look 
like this:

var Number percent = 0

rule "Dimmed Light"
    when
        Item licht_schrank received command
    then
        if(licht_schrank.state instanceof DecimalType) percent = licht_schrank.state as DecimalType 

        if(receivedCommand==ON) percent = 100
        if(receivedCommand==OFF) percent = 0
        if(receivedCommand==INCREASE) percent = percent + 5
        if(receivedCommand==DECREASE) percent = percent - 5

        if(percent<0)   percent = 0
        if(percent>100) percent = 100
        postUpdate(licht_schrank, percent);
        sendHttpPostRequest("http://10.1.2.38/analogWrite?pin=3&value=" + percent);
end

The classicUI is still working while the problems with greent are unchanged. 
The webserver logs tell me greent is always sending the old value. For example 
if the dimmer is switched off and I move the slider to the right, the webserver 
logs the following request from openhab: "POST /analogWrite?pin=3&value=0 
HTTP/1.1"

Original comment by stefanm4...@googlemail.com on 12 Jul 2013 at 6:57

GoogleCodeExporter commented 8 years ago
I figured out I need another rule for greent:

rule "Dimmed Light2"
        when
                Item licht_schrank received update
        then
                sendHttpPostRequest("http://192.168.178.1/analogWrite?pin=3&value=" + licht_schrank.state.format("%d"));
end

Now it is working. Sorry for issuing a bug report. Please close this issue.
Stefan

Original comment by stefanm4...@googlemail.com on 12 Jul 2013 at 8:48

GoogleCodeExporter commented 8 years ago
Does this mean that the GreenT UI sends a status update and not a command? If 
this is the case, I would consider it as a bug of the GreenT UI.

Original comment by kai.openhab on 12 Jul 2013 at 8:51

GoogleCodeExporter commented 8 years ago
@Stefan could you please confirm (or reject) Kai's statement?
@Mihail if that's the case it appears to be your turn ;-)

Original comment by teichsta on 13 Aug 2013 at 8:07

GoogleCodeExporter commented 8 years ago
Hi guys, sorry for the late response. I think this is an issue with how openHAB 
deals with this kind of items.

If you make a POST HTTP request to e.g. the Volume demo item 
(http://localhost:8080/rest/items/Volume/) with body payload "57", openHAB logs 
shows this:

14:06:57.204 INFO  runtime.busevents[:42] - Volume received command 57
14:06:57.240 INFO  runtime.busevents[:46] - Volume state updated to 57.000076

If you click on some of the UP/DOWN buttons of the same item in the Classic UI, 
this is what openHAB logs:

14:16:02.280 INFO  runtime.busevents[:42] - Volume received command INCREASE
14:16:02.296 INFO  runtime.busevents[:46] - Volume state updated to 82.0798

So, I think there is some kind of a logic behind this item type that updates 
the state on receiving a command, but doesn't fire a "command event".

Original comment by mishoboss on 20 Sep 2013 at 11:23

GoogleCodeExporter commented 8 years ago

Original comment by kai.openhab on 6 Nov 2013 at 8:34

GoogleCodeExporter commented 8 years ago
This issue has been migrated to Github. If this issue id is greater than103 its 
id has been preserved on Github. You can open your issue by calling the URL 
https://github.com/openhab/openhab/issues/<issueid>. Issues with ids less or 
equal 103 new ids were created.

Original comment by teichsta on 17 Nov 2013 at 8:08

GoogleCodeExporter commented 8 years ago
see above!

Issue has been migrated to Github and should be discussed there.

Original comment by teichsta on 21 Nov 2013 at 1:51