mvalla / openhab-addons

Add-ons for openHAB
Eclipse Public License 2.0
24 stars 16 forks source link

rollershutter items do not track changes in movement from external commands #63

Open weltraumbagger opened 5 years ago

weltraumbagger commented 5 years ago

when closing rollershutter by activating in sitemap or paperui i receive "item ... received command down" in the log:

2019-03-09 11:17:42.761 [ome.event.ItemCommandEvent] - Item 'iEG_Ro_BueroFenster' received command DOWN

2019-03-09 11:17:42.774 [nt.ItemStatePredictedEvent] - iEG_Ro_BueroFenster predicted to become DOWN

2019-03-09 11:17:42.776 [DEBUG] [ebnet.handler.OpenWebNetThingHandler] - ==OWN:ThingHandler== handleCommand() (command=DOWN - channel=openwebnet:bus_automation:MH200N:EG_Ro_BueroFenster:shutter)

2019-03-09 11:17:42.795 [vent.ItemStateChangedEvent] - iEG_Ro_BueroFenster changed from 26 to 100

2019-03-09 11:17:45.206 [ome.event.ItemCommandEvent] - Item 'iEG_Ro_BueroFenster' received command STOP

2019-03-09 11:17:45.214 [DEBUG] [ebnet.handler.OpenWebNetThingHandler] - ==OWN:ThingHandler== handleCommand() (command=STOP - channel=openwebnet:bus_automation:MH200N:EG_Ro_BueroFenster:shutter)

2019-03-09 11:17:45.400 [vent.ItemStateChangedEvent] - iEG_Ro_BueroFenster changed from 100 to 45

this is pretty important if i want to start a rule when shutter closes.

but when i close rollershutter by a touchscren, mh200n or with an external app then only this is logged and it cannot be triggered by a rule: 2019-03-09 11:22:48.466 [vent.ItemStateChangedEvent] - iEG_Ro_BueroFenster changed from 45 to 55

Gozilla01 commented 5 years ago

Do a test with the binding version 2.5.0-M2. No problem either from PaperUI, BasicUi and OpenHAB App for the rules work properly. The rules do not work from OWN commands

rule "Da Simula Rollshutter "
  when
    Item Tapparella_Sala received command
  then
    logInfo("Rules" , "Da Simula Rollshutter")  
    switch(receivedCommand ) {
      case UP: {
            logInfo("Rules" , "Da Simula Rollshutter UP")
      }
      case STOP: {
            logInfo("Rules" , "Da Simula Rollshutter STOP")
      }
      case DOWN: {
            logInfo("Rules" , "Da Simula Rollshutter DOWN")
      }
    }
end
weltraumbagger commented 5 years ago

binding version 2.5.0-M2 is installed since today in the morning.

you are right, no problem from paperui, basicui and openhab-app. BUT when you try it from a touchscreen or if the command was sent from mh200n your rule will not trigger if it expects "when shutter received command down".

similar problem for lights: if you switch lights on/off from paperui, basicui or openhab-app, a rule is able to trigger a "received command on/off", but if you press a physical switch this rule cannot trigger. here you can use "changed to on/off", but for rollershutters this is difficult to manage in a rule because there only the changed position is published

Gozilla01 commented 5 years ago

The problem that the status of a shutter is expressed in numerical value (percentage)

weltraumbagger commented 5 years ago

correct! please have a look at my first post with the log-files: when i close a shutter from openhab i receive

Item 'iEG_Ro_BueroFenster' received command DOWN

in the log, this i don´t have when i close the shutter from a touchscreen.

so if i want to trigger a rule when closing a shutter i must not use the "received command down" because this does not always work.

actually i have no idea how i can make the rule work properly, i supposed this would be not quite correct as it is now.

mvalla commented 5 years ago

"received command down" will only trigger when a command is sent to a channel from OH (rest API, paperui, apps, whatever). so this is normal. The thing that is not normal is that when you control the shutter from touchscreen or other physical device, the status of the channel is not updated to DOWN. In fact this makes me thing that probably 2 channels are needed here and not just one: 1 for position (to be updated when position is changed and to receive percent commands), and 1 for state (STOP, UP or DOWN) and to receive movement commands. So for example when you press down from a pysical device you would get; position channel goes: from current position to new position state channel goes: from STOP to DOWN to STOP again. I will think about it if really a second channel is needed (i will have to look to other bindngsm what they do there).

Meanwhile you should send me the logs from official openwebnet app with Monitor activated to show what happens in your case then a Down command is sent from a physical device. <<

Massimo

Gozilla01 commented 5 years ago

I did a lot of research to find out if there was a solution to make the rules work, but nothing because the field is a percentage value. I performed an implementation with a second channel, string shutterState ,it seems to work from the tests. State String "UP" "DOWN" "STOP"

Rollershutter  Tapparella_Sala "Sala [%.0f %%]" {channel="openwebnet:bus_automation:mybridge:mytap_sala:shutter" }
String Tapparella_SalaUpDownStop "Sala" { channel="openwebnet:bus_automation:mybridge:mytap_sala:shutterState" }
rule "Da Simula Rollshutter "
  when
    Item Tapparella_SalaUpDownStop changed
  then
    switch(Tapparella_SalaUpDownStop.state ) {
      case "UP": {
            logInfo("Rules" , "Da Simula Rollshutter UP")
      }
      case "STOP": {
            logInfo("Rules" , "Da Simula Rollshutter STOP")
      }
      case "DOWN": {
            logInfo("Rules" , "Da Simula Rollshutter DOWN")
      }
    }
end

@massi, I did not do a PR, I would like your confirmation first if you agree to this solution.

mvalla commented 5 years ago

is there any other binding in OH that has two channels for a shutter device? one for position and one for state?

mvalla commented 5 years ago

as suggested here the final solution is to add a second channel shutterMotion to the bus_automation thing with type Number and possible values 0, 1, 2 to be mapped to the corresponding OWN values and to be transformed to STOP, UP, DOWN by users using transformations. Transformation should then be usable also in rules (case "UP"/"DOWN"/"STOP", to be checked). The current channel shutter could also be renamed to shutterPosition (breaking change), but this could be done later.