steilerDev / homebridge-openhab2-complete

A homebridge plugin for openHAB, that has the expectation to fully support all Services offered by Apple's Homekit Accessory Protocol (HAP)
GNU General Public License v3.0
52 stars 16 forks source link

Support for Insteon Fanlinc which require item tagged as NUMBER #7

Closed RFila closed 5 years ago

RFila commented 5 years ago

Now that I've got the plugin running on Docker, I'm trying to map my Insteon Fans into the system with the following config:

Insteon Items contains this as required by the Insteon PLM module: Number LivingRoom_Fan "Living Room Fan" {insteonplm="14.F5.2A:F00.00.1C#fan"}

As I noticed in your plugin, the FAN section is looking for the item to be tagged as a switch so it errors out on the mapping. I tried changing the mapping in the items file to a switch but that fails to bind the Insteon device.

In my sitemap, here is how the Insteon Fan is controlled:
Switch item=LivingRoom_Fan label="Living Room Fan" mappings=[ 0="OFF", 1="LOW", 2="MEDIUM", 3="HIGH"]

Funny thing about this whole situation is that when I was using the Insteon Hub PRO (which is there way of accessing HomeKit (but Failed after about 3 years of service and they wanted to charge me almost full price to replace the PoS) the corresponding interacting icon that came up in Home was actually a fully variable slider instead of any sort of button scheme with Off, Low, Med, & High and it responded pretty close to fully variable - it didn't seem to have any Low, or Med demarks in the power scale.

So - all this to say, can you tweak the plugin to allow Number to be a valid option for the Fan item with a Low, Medium or fully variable option or perhaps have have another alternative idea of how I could map these and access my fanlincs?

steilerDev commented 5 years ago

Hi @RFila ,

I really liked your input and looked into it. With my latest commit on the V0.9.0 branch (44925d9d2ea0910aa5112bbd466e871f1ea65d2b) I changed the fan accessory to support Switch, Number and Dimmer item types, in order to support controlling the fan speed. This will support your use case partially.

The expected number range is 0 to 100(%). Therefore you will need to create a proxy item that will map the percentage speed to your discrete steps. Potentially something like that:

fan.items

Number LivingRoom_Fan "Living Room Fan" {insteonplm="14.F5.2A:F00.00.1C#fan"}
Number LivingRoom_Fan_HK (fan_hk)

fan_hk.rules

rule "Homekit send fan command"
when
    Member of fan_hk received command
then
    val ruleName = "hk_rollershutter_command"
    val fan = triggeringItem as NumberItem
    val fanDeviceName = fan.name.replaceAll("_HK", "")
    val command = 0
    if(receivedCommand > 0 && receivedCommand < 33) {
        command = 1
    } else if (receivedCommand >=33 && receivedCommand < 66) {
        command = 2
    } else if (receivedCommand >= 66 && receivedCommand <= 100) {
        command = 3
    }
    logInfo(ruleName, fan.name + " received command " + command + " sending it to " + fanDeviceName)
    sendCommand(fanDeviceName, command)
end

Please manually remove the npm version and install the latest version

npm uninstall homebridge-openhab2-complete
git clone https://github.com/steilerDev/homebridge-openhab2-complete.git
git checkout V0.9.0
cd homebridge-openhab2-complete
npm install -g .

And restart homebridge.

If there is any unexpected behavior, please start Homebridge in debug mode and post the logs here. Otherwise please close the issue if this meets your expectations and I will merge the feature in the upstream npm release.

RFila commented 5 years ago

This is excellent.

Just to verify, when I do the update, I need to be inside the docker-compose instance, correct?

On Wed, Feb 13, 2019 at 5:42 AM Frank Steiler notifications@github.com wrote:

Hi @RFila https://github.com/RFila ,

I really liked your input and looked into it. With my latest commit on the V0.9.0 branch (44925d9 https://github.com/steilerDev/homebridge-openhab2-complete/commit/44925d9d2ea0910aa5112bbd466e871f1ea65d2b) I changed the fan accessory to support Switch, Number and Dimmer item types, in order to support controlling the fan speed. This will support your use case partially.

The expected number range is 0 to 100(%). Therefore you will need to create a proxy item that will map the percentage speed to your discrete steps. Potentially something like that:

fan.items

Number LivingRoom_Fan "Living Room Fan" {insteonplm="14.F5.2A:F00.00.1C#fan"} Number LivingRoom_Fan_HK (fan_hk)

fan_hk.rules

rule "Homekit send fan command" when Member of fan_hk received command then val ruleName = "hk_rollershutter_command" val fan = triggeringItem as NumberItem val fanDeviceName = fan.name.replaceAll("_HK", "") val command = 0 if(receivedCommand > 0 && receivedCommand < 33) { command = 1 } else if (receivedCommand >=33 && receivedCommand < 66) { command = 2 } else if (receivedCommand >= 66 && receivedCommand <= 100) { command = 3 } logInfo(ruleName, fan.name + " received command " + command + " sending it to " + fanDeviceName) sendCommand(fanDeviceName, command) end

Please manually remove the nom version and install the latest version

ppm uninstall homebridge-openhab2-complete git clone https://github.com/steilerDev/homebridge-openhab2-complete.git git checkout V0.9.0 cd homebridge-openhab2-complete npm install -g . `` And restart homebridge.

If there is any unexpected behavior, please start Homebridge in debug mode and post the logs here. Otherwise please close the issue if this meets your expectations and I will merge the feature in the upstream npm release.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/steilerDev/homebridge-openhab2-complete/issues/7#issuecomment-463150070, or mute the thread https://github.com/notifications/unsubscribe-auth/AtSl2I1kQXeHVH1A-2aqo5QCFiUiIbakks5vM-wdgaJpZM4a1oDF .

steilerDev commented 5 years ago

Yes. The way I did it was to create a folder inside the volume where your config.json is. I called it custom_node_modules. I git cloned the repository in there. In the startup.sh I then added npm install -g /homebridge/custom_node_modules/homebridge-openhab2-complete/.

RFila commented 5 years ago

Watching the log files, this is working as expected (Data coming back from Homebridge with the % I set the fan in the Home app.) I'm going to build out the rules now and see how that works - this part will be new for me. Thanks so much for your help.

One additional bonus from bumping to build 0.9.0 - For some reason, even though I had tried changing the port and outright removing the Config-UI-X lines from the Docker-Compose file, it wasn't grabbing the changes and still trying to load Config-UI-X on port 8080 even though OpenHab is on that port. It was throwing errors in the log every 10 seconds or so. It's stopped now.

RFila commented 5 years ago

Okay - Once I figured out what you intended (mapping the Home app interface to the Intermediary (_HK), It took me a step further. Here's the error I'm getting in OH2 Logs:

`2019-02-13 21:51:19.735 [INFO ] [marthome.model.script.hk_fan_command] - LivingRoom_Fan_HK received command 1 sending it to LivingRoom_Fan

2019-02-13 21:51:19.753 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Homekit send fan command': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null`

Here's the output from using the Sitemap to switch the Fan to Low speed: ==> /var/log/openhab2/events.log <== 2019-02-13 21:55:16.064 [ome.event.ItemCommandEvent] - Item 'LivingRoom_Fan' received command 1 ==> /var/log/openhab2/openhab.log <== 2019-02-13 21:55:16.076 [INFO ] [g.insteonplm.InsteonPLMActiveBinding] - Item: LivingRoom_Fan got command 1 2019-02-13 21:55:16.090 [INFO ] [onplm.internal.device.CommandHandler] - FanLincFanCommandHandler: sent msg to change level to 1 ==> /var/log/openhab2/events.log <== 2019-02-13 21:55:16.101 [vent.ItemStateChangedEvent] - LivingRoom_Fan changed from 0.0 to 1 ==> /var/log/openhab2/openhab.log <==

One additional note - Prior to invoking the "_HK" (when I had the item mapped just to LivingRoom_Fan, if I just put the called the fan directly and put it at 1, 2, or 3%, it turned the fan on Low, Medium or High. So I feel I'm getting closer but not quite sure what to call from the rule at this point.

Any thoughts?

RFila commented 5 years ago

Figured it out - Needed " " around the 0, 1, 2, & 3 for the command ='s for them to pass as strings through the sendcommand(). All good now!!!

This works great! Thanks so much!