hobbyquaker / homekit2mqtt

HomeKit to MQTT bridge 🏡📱
MIT License
349 stars 71 forks source link

Velux Bind: Anyone got WindowCovering service working? #167

Closed njh closed 3 years ago

njh commented 3 years ago

I have been using homekit2mqtt for a little while now, to control my lights, central heating and display temperatures using HomeKit - thanks @hobbyquaker! I have recently managed to control my Velux RSL Roller Binds by circuit-modding a remote control to fake button presses using an Arduino. And hooked it up to MQTT using Node-RED.

However I am having trouble with getting a WindowCovering service working. I am seeing messages pubished to the setTargetPosition topic Ok. But then the Home app gets stuck saying 'Opening...' or 'Closing...' and doesn't seem to respond to messages published to statusCurrentPosition or statusPositionState.

Here is a screen recording on my Mac after pressing the tile: blinds-opening

As far as I can tell the debug messages look like they are working correctly.

I have targetPositionFactor and currentPositionFactor using the default values of 1. So blinds open = 100 and blinds closed = 0.

I am using the following to simulate my blinds:

mosquitto_pub -t 'living-room/velux/blinds/currentPosition' -m 0
mosquitto_pub -t 'living-room/velux/blinds/positionState' -m opening
mosquitto_pub -t 'living-room/velux/blinds/currentPosition' -m 100
mosquitto_pub -t 'living-room/velux/blinds/positionState' -m stopped

Here is the contents of the homekit2mqtt logs - which all seems fine to me:

2020-11-28 20:50:40.230 <debug> mqtt subscribe living-room/velux/blinds/currentPosition
2020-11-28 20:50:40.235 <debug> mqtt subscribe living-room/velux/blinds/positionState
2020-11-28 20:50:40.427 <debug> < mqtt living-room/velux/blinds/currentPosition 100 100
2020-11-28 20:50:40.428 <debug> > hap update Velux Blinds CurrentPosition 100
2020-11-28 20:50:40.429 <debug> < mqtt living-room/velux/blinds/positionState opening opening
2020-11-28 20:50:40.430 <debug> > hap update Velux Blinds PositionState.INCREASING
2020-11-28 20:50:48.233 <debug> < mqtt living-room/velux/blinds/positionState opening opening
2020-11-28 20:50:48.233 <debug> > hap update Velux Blinds PositionState.INCREASING
2020-11-28 20:51:16.542 <debug> < mqtt living-room/velux/blinds/currentPosition 0 0
2020-11-28 20:51:16.543 <debug> > hap update Velux Blinds CurrentPosition 0
2020-11-28 20:51:43.172 <debug> < mqtt living-room/velux/blinds/positionState opening opening
2020-11-28 20:51:43.173 <debug> > hap update Velux Blinds PositionState.INCREASING
2020-11-28 20:52:18.336 <debug> < mqtt living-room/velux/blinds/currentPosition 100 100
2020-11-28 20:52:18.337 <debug> > hap update Velux Blinds CurrentPosition 100
2020-11-28 20:52:30.237 <debug> < mqtt living-room/velux/blinds/positionState opening opening
2020-11-28 20:52:30.238 <debug> > hap update Velux Blinds PositionState.INCREASING
2020-11-28 20:52:37.498 <debug> < mqtt living-room/velux/blinds/positionState NaN 
2020-11-28 20:52:37.498 <debug> > hap update Velux Blinds PositionState.STOPPED
2020-11-28 21:33:45.651 <debug> < hap get Velux Blinds CurrentPosition
2020-11-28 21:33:45.652 <debug> > hap re_get Velux Blinds CurrentPosition 100

And here is my configuration section:

  "living-room-blinds": {
    "name": "Living Room Velux Window",
    "manufacturer": "Velux",
    "category": 14,
    "services": [
      {
        "name": "Velux Blinds",
        "service": "WindowCovering",
        "topic": {
          "setTargetPosition": "living-room/velux/blinds/targetPosition",
          "statusCurrentPosition": "living-room/velux/blinds/currentPosition",
          "statusPositionState": "living-room/velux/blinds/positionState"          
        },
        "payload": {
          "positionStatusDecreasing": "closing",
          "positionStatusIncreasing": "opening"
        },
        "config": {},
        "props": {}
      }
    ]
  }

Has anyone got a WindowCovering service working? Any idea what I am doing wrong? The CurrentPosition doesn't seem to be displayed in the Home.app? Is it used? Should the PositionState be used to update the current state of the tile in the app?

Thanks!

nick.

njh commented 3 years ago

I have no idea why I was struggling with this but I have it working fine now.

I found that positionState did very little in the Apple Home app, so I have removed it from my configuration.

Here is my config:

  "living-room-blinds": {
    "name": "Living Room Velux Window",
    "manufacturer": "Velux",
    "category": 14,
    "services": [
      {
        "name": "Velux Blinds",
        "service": "WindowCovering",
        "topic": {
          "setTargetPosition": "living-room/velux/blinds/command",
          "statusTargetPosition": "living-room/velux/blinds/target_position",
          "statusCurrentPosition": "living-room/velux/blinds/current_position"
        },
        "payload": {},
        "config": {},
        "props": {}
      }
    ]
  }

I listen to the command topic for instructions what to do and then update target_position and current_position.

I hope if someone finds this, having the same problem, it helps them in some way.

njh commented 3 years ago

Reopening as I haven't got it working completely after all. It is working fine on Home.app (Version 4.0 (367.7)) on my Mac but not on my iPhone (iOS 14.2).

I have done some testing with the HomeKit simulator and that is working fine. So I think there must be a bug somewhere....

njh commented 3 years ago

I did some more testing and got a Window Covering behaving correctly using homebridge-mqttthing instead:

        {
            "accessory": "mqttthing",
            "type": "windowCovering",
            "name": "Living Room Blinds",
            "topics": {
                "getCurrentPosition": "living-room/blinds/current-position",
                "getPositionState": "living-room/blinds/state",
                "getTargetPosition": "living-room/blinds/target-position",
                "setTargetPosition": "living-room/blinds/command"
            },
            "positionStateValues": [
                "closing",
                "opening",
                "stopped"
            ]
        }

There were some Homebridge plugins I wanted to try using anyway, so decided to make the switch away from homekit2mqtt.

Thanks for homekit2mqtt, I happily used it for a long time!