stefan-kaestle / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
16 stars 1 forks source link

Add shutter control write #26

Closed tuxianerDE closed 3 years ago

tuxianerDE commented 3 years ago

Currently the shutter control offers the read function of the current position in numeric value that I convert into %.

If shutters shall be controller a corresponding set function is required. At least querying the interface did not lead to a successful movement for my shutters.

coeing commented 3 years ago

@tuxianerDE Could you give me some details about your setup? Setting a specific shutter level is already possible (the ShutterControlHandler handles the PercentType command). But you may have a setup where a different command is send to the handler. I should be able to find out which one it is and handle it correctly if I can mirror your setup :)

tuxianerDE commented 3 years ago

Sure. Here is the thing config:

Thing shutter-control schlafzimmerrolladenfenster "Schlafzimmer Fenster" @ "Schlafzimmer" [ id="hdm:HomeMaticIP:3014FXXXXXXXXXXXXXX" ]

Item:

//Rolladen Schlafzimmer Number SchlafzimmerCurrentRolladenPosition "Aktuelle Rolladenposition [MAP(boschrolladencontrol.map):%s]" (persSwitch) { channel="boschshc:shutter-control:holzgasse:schlafzimmerrolladenfenster:level", autoupdate="true" }

(the map does only convert 0.0 to OPEN and 1.0 to CLOSED)

Sitemap: in Simple terms it users a slider.

Rule to convert fomr % to decimal 0.: rule "Convert Percent into Bosch value" when Item GaestezimmerFensterCurrentRolladenPosition_percent received update then SchlafzimmerCurrentRolladenPosition.sendCommand((GaestezimmerFensterCurrentRolladenPosition_percent.state as DecimalType) / 100) end

coeing commented 3 years ago

@tuxianerDE Looks like you send a DecimalType command to the handler which is not handled right now. If you send a PercentType command instead it should work. But I will try to reproduce the issue and add the handling of the DecimalType command if my theory is true.

coeing commented 3 years ago

@tuxianerDE I managed to reproduce your issue. The command was of type PercentType, but you did a division by 100, so the value was always too small to be considered.

This rule works for me:

rule "Shutter Test"
when
    Item ShutterControl_Level received update
then
    ShutterControl_Eating_Level.sendCommand(ShutterControl_Level.state)
end

Please let me know if it works for you without the division as well.

tuxianerDE commented 3 years ago

I have done the change but at least from remote I dont see any movement at home, I can see the following in the logs now.

2020-08-13 10:29:03.774 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Convert Percent into Bosch value': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null 2020-08-13 10:29:12.899 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Convert Percent into Bosch value': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

My rule looks now like: rule "Convert Percent into Bosch value" when Item GaestezimmerFensterCurrentRolladenPosition_percent received update then GaestezimmerFensterCurrentRolladenPosition.sendCommand(GaestezimmerFensterCurrentRolladenPosition_percent.state) end

coeing commented 3 years ago

@tuxianerDE Unfortunately I never saw this kind of error before. But it looks like (on instance: null) like the thing GaestezimmerFensterCurrentRolladenPosition couldn't be found. Could you please double check that it exists and is online, e.g. in Paper UI?

Also in your first setup you sent the command to SchlafzimmerCurrentRolladenPosition, maybe you have a copy&paste error there? :)

tuxianerDE commented 3 years ago

Hey, updated my code now also with the latest release and my shutters are still not moving a single inch :(

I can see that the value gets set to the item I have configured for Bosch but there is no reaction to it. I have auto update enabled for the item, does that make a difference? I would not expect so?

coeing commented 3 years ago

@tuxianerDE No, it shouldn't make a difference as far as I know. Could you post your code again so I can try it myself? And does the log show any errors or warnings?

tuxianerDE commented 3 years ago

The log show nada - They show that the rule gets applied and the calculation is done. here are the pieces:

Thing: Thing shutter-control gaestezimmerrolladenfenster "Gästezimmer Fenster" @ "Gästezimmer" [ id="hdm:HomeMaticIP:3014F711A00018DA18591182" ]

Item: //Rolladen Gästezimmer" Number GaestezimmerFensterCurrentRolladenPosition "Aktuelle Rolladenposition" (persSwitch) { channel="boschshc:shutter-control:holzgasse:gaestezimmerrolladenfenster:level", autoupdate="true" } Number GaestezimmerFensterCurrentRolladenPosition_percent "[%.1f Percent]" (persPerfData)

Sitemap: Frame label="Gästezimmer" icon="groundfloor" { Default item=GaestezimmerFensterCurrentRolladenPosition label="Aktuelle Rolladen Position Fenster" Slider item=GaestezimmerFensterCurrentRolladenPosition_percent }

Rule: rule "Convert Percent into Bosch value" when Item GaestezimmerFensterCurrentRolladenPosition_percent received update then GaestezimmerFensterCurrentRolladenPosition.sendCommand((GaestezimmerFensterCurrentRolladenPosition_percent.state)) logInfo("Calculation", "berechnung wurde vorgenommen.") end

coeing commented 3 years ago

@tuxianerDE The only thing that looks strange for me is the "holzgasse:" inside the channel which the first item connects to. But I have to say that I currently do my configuration via Paper UI instead of the configuration files. Maybe @GerdZanker or @stefan-kaestle could have a look at your setup? They probably have more experience with a setup via configuration files.

tuxianerDE commented 3 years ago

That is coming from my overall Bridge boschshc:shc:holzgasse

and I works for the other items like light switches.

coeing commented 3 years ago

I thought so. Will try to use your setup in my home now to find the cause.

tuxianerDE commented 3 years ago

Much appreciated :)

coeing commented 3 years ago

@tuxianerDE I think I found the issue. Your item GaestezimmerFensterCurrentRolladenPosition_percent is a Number item, so it provides a DecimalType. But the level channel requires a PercentType command. So you have to convert it:

rule "Convert Percent into Bosch value"
when
    Item GaestezimmerFensterCurrentRolladenPosition_percent received update
then
    val state = GaestezimmerFensterCurrentRolladenPosition_percent.state as DecimalType
    logInfo("Calculation", "Doing state update: {}", state)
    GaestezimmerFensterCurrentRolladenPosition.sendCommand(new PercentType(state.intValue()))
    logInfo("Calculation", "State update done: {}", state)
end

But in your current setup, you could also just remove the GaestezimmerFensterCurrentRolladenPosition_percent item and use the GaestezimmerFensterCurrentRolladenPosition item directly. This works for me:

Sitemap:

    Frame label="Gästezimmer" icon="groundfloor" {
        Slider item=GaestezimmerFensterCurrentRolladenPosition
    }

Items:

Rollershutter GaestezimmerFensterCurrentRolladenPosition "Aktuelle Rolladenposition" {channel="boschshc:shutter-control:1:gaestezimmerrolladenfenster:level"}
tuxianerDE commented 3 years ago

ahh hangon more prominently it is the item typ you use. Rollershutter I have not been using .. instead I had Number there too. Changing the item here made the difference!

issue resolved. thank you for your help on that!!!

coeing commented 3 years ago

@tuxianerDE I see, so the conversion is probably done automatically if you use the correct item type 👍 We should probably put some information somewhere which channels exists and which item type they require.