Git Product home page Git Product logo

homekit2mqtt's Introduction

homekit2mqtt

mqtt-smarthome NPM version dependencies Status Build Status Coverage Status XO code style License

HomeKit to MQTT bridge 🏡📱

Depends on HAP-NodeJS by KhaosT, all credits belong to him.

This project follows the mqtt-smarthome architecture. I'm using this to control a multitude of MQTT-connected "Things" in my home automation through Siri and with HomeKit apps.

Warning: Version 0.9.4 possibly introduces a breaking change. Due to the issue #89 service subtypes where added, please give your Home app a few minutes to get updates, if the accessories don't work at all anymore after an update from <=0.9.3 to >=0.9.4 you have to delete the persistence files and delete and re-add the bridge in iOS...:-(

Installation

Requirements

  • Debian, Ubuntu, Raspbian or macOS
  • Node.js 6 or higher
  • If you want to use the Camera Service FFmpeg has to be installed (on Linux: sudo apt install ffmpeg)

sudo npm install -g homekit2mqtt --unsafe-perm

I suggest to use pm2 to manage the homekit2mqtt process (start on system boot, manage log files, ...)

Command Line Options

Usage: homekit2mqtt [options]

Options:
  -v, --verbosity       possible values: "error", "warn", "info", "debug"
                                                               [default: "info"]
  -m, --mapfile         JSON file containing HomeKit Services to MQTT mapping
                        definitions. See Readme.                       [default:
                                                  "./example-homekit2mqtt.json"]
  -n, --name            instance name. used as prefix for connected topic
                                                            [default: "homekit"]
  -u, --url             mqtt broker url.           [default: "mqtt://127.0.0.1"]
  -s, --storagedir      directory to store homekit data
  -p, --port            port homekit2mqtt is listening on       [default: 51826]
  -w, --web-port        port webserver is listening on          [default: 51888]
  -x, --disable-web     disable webserver
  --disable-json-parse  disable json parsing of received mqtt payloads [boolean]
  --insecure            allow tls connections with invalid certificates[boolean]
  --retain              if set, ALL MQTT messages sent will have the retain flag
                        set                                            [boolean]
  -h, --help            Show help                                      [boolean]
  --version             Show version number                            [boolean]
  -c, --pincode                                          [default: "031-45-154"]
  -a, --username                                  [default: "CC:22:3D:E3:CE:F6"]
  -b, --bridgename                                      [default: "MQTT Bridge"]

                                                             

Persisted Data

I strongly advice you to set the --storagedir and --mapfile option to a directory outside of the homekit2mqtt folder, otherwise an update of homekit2mqtt could overwrite your config.

MQTT Authentication and TLS

You can put credentials for authentication in the url supplied to the --url option: mqtt://user:password@broker. If you want to use TLS for the connection to the broker use mqtts:// as URL scheme, e.g. mqtts://broker:8883.

MQTT Payload parsing

By default homekit2mqtt parses incoming JSON payloads and tries to use the attribute val (following mqtt-smarthome payload convention). For a future release it is planned that this attribute will be configurable (see #67).

If you set the --disable-json-parse option there will be no JSON parsing at all and homekit2mqtt just hands the incoming JSON through as string.

Plain (non-JSON) payloads containing the strings true or false are casted to boolean. Strings containing numbers are casted to numbers with parseFloat().

Configuration

homekit2mqtt needs a JSON file that defines devices and mappings from MQTT-topics and payloads to HomeKit-characteristics. You can either create this manually or use the Web UI to configure homekit2mqtt. The Webserver listens on Port 51888 by default, authentication username is homekit and the password is the pincode (031-45-154 by default).

Web UI Web UI

See example-homekit2mqtt.json for an example configuration. Every Accessory is represented like this in the JSON file:

  "TemperatureSensor": {                                    // Unique name - used to generate the accessory UUID
    "name": "TemperatureSensor LivingRoom",                 // Accessory name
    "services": [
        {
            "service": "TemperatureSensor",                 // HomeKit service type (see available service types below)
            "name": "Temperature LivingRoom",               // Service name
            "topic": {                                              
                // ... MQTT topic configuration ...
            },
            "payload": {
                // ... MQTT payload configuration ...
            },
            "props": {
                // ... Optional Characteristic properties
            },
            "config": {
                // ... Optional Service configuration
            }       
        },
        // ... more services
    ],
    "manufacturer": "DIY Home Brew",                        // Additional accessory infos (optional)
    "model": "TemperatureSensor"                            // Additional accessory infos (optional)
  }

Available Service Types

AirPurifier

topic

  • statusActive
  • setActive
  • statusCurrentAirPurifierState
    0 = INACTIVE, 1 = IDLE, 2 = PURIFYING_AIR
  • statusTargetAirPurifierState
    0 = MANUAL, 1 = AUTO
  • setTargetAirPurifierState
    0 = MANUAL, 1 = AUTO
  • statusLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • setLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • statusSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • setLockSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • statusRotationSpeed (optional)
    Percentage 0-100
  • setRotationSpeed (optional)
    Percentage 0-100

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • rotationSpeedFactor (optional, default: 1)

AirQualitySensor

topic

  • statusAirQuality
    0 = UNKNOWN, 1 = EXCELLENT, 2 = GOOD, 3 = FAIR, 4 = INFERIOR, 5 = POOR
  • statusOzoneDensity (optional)
  • statusNitrogenDioxideDensity (optional)
  • statusSulphurDioxideDensity (optional)
  • statusPM2_5Density (optional)
  • statusPM10Density (optional)
  • statusVOCDensity (optional)
  • statusCarbonMonoxideLevel (optional)
  • statusCarbonDioxideLevel (optional)
  • onLowBattery (optional)
  • onTampered (optional)
  • onActive (optional)
  • onFault (optional)

payload

  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

BatteryService

topic

  • statusBatteryLevel
    Percentage 0-100
  • statusChargingState
    0 = NOT_CHARGING, 1 = CHARGING, 2 = NOT_CHARGEABLE
  • statusLowBattery
    0 = BATTERY_LEVEL_NORMAL, 1 = BATTERY_LEVEL_LOW

payload

  • onLowBattery
  • invertLowBattery (optional, default: false)
  • minBatteryLevel (optional, default: 0)
  • maxBatteryLevel (optional, default: 100)

CameraRTSPStreamManagement

topic

payload

config

  • source (default: -re -i rtsp://myfancy_rtsp_stream)
  • stillImageSource (default: -i http://faster_still_image_grab_url/this_is_optional.jpg)
  • maxStreams (default: 2)
    the maximum number of streams that will be generated for this camera
  • maxWidth (default: 1280)
  • maxHeight (default: 720)
  • maxFPS (default: 10)
    the maximum frame rate of the stream
  • maxBitrate (default: 300)
    the maximum bit rate of the stream in kbit/s
  • vcodec (default: libx264)
    If you're running on a RPi with the omx version of ffmpeg installed, you can change to "h264_omx" for hardware accelerated video codec
  • audio
    can be set to true to enable audio streaming from camera. To use audio ffmpeg must be compiled with --enable-libfdk-aac, see https://github.com/KhaosT/homebridge-camera-ffmpeg/wiki
  • packetSize (default: 1316)
    If audio or video is choppy try a smaller value, set to a multiple of 188
  • debug
    Show the output of ffmpeg in the log
  • videoProcessor (default: ffmpeg)

CarbonDioxideSensor

topic

  • statusCarbonDioxideDetected
  • statusCarbonDioxideLevel (optional)
  • statusCarbonDioxidePeakLevel (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onCarbonDioxideDetected
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

CarbonMonoxideSensor

topic

  • statusCarbonMonoxideDetected
  • statusCarbonMonoxideLevel (optional)
  • statusCarbonMonoxidePeakLevel (optional)
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onCarbonMonoxideDetected
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

ContactSensor

topic

  • statusContactSensorState
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onContactDetected
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

Door

topic

  • setTargetPosition
  • statusTargetPosition (optional)
  • statusCurrentPosition (optional)
  • statusPositionState (optional)
  • statusObstruction (optional)
  • setHoldPosition (optional)

payload

  • targetPositionFactor (optional)
  • currentPositionFactor (optional)
  • positionStatusDecreasing (optional)
  • positionStatusIncreasing (optional)
  • onObstructionDetected (optional)
  • holdPositionTrue (optional, default: true)
  • holdPositionFalse (optional, default: false)

Doorbell

topic

  • statusEvent

payload

Fan

topic

  • setOn
  • statusOn (optional)
  • setRotationDirection (optional)
  • statusRotationDirection (optional)
  • setRotationSpeed (optional)
  • statusRotationSpeed (optional)

payload

  • onTrue (optional, default: true)
  • onFalse (optional, default: false)
  • rotationDirectionCounterClockwise (optional, default: 1)
  • rotationDirectionClockwise (optional, default: 0)
  • rotationSpeedFactor (optional, default: 1)

Fanv2

topic

  • statusActive
  • setActive
  • statusCurrentFanState
    0 = INACTIVE, 1 = IDLE, 2 = PURIFYING_AIR
  • statusTargetFanState
    0 = MANUAL, 1 = AUTO
  • setTargetFanState
    0 = MANUAL, 1 = AUTO
  • statusLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • setLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • statusSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • setLockSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • statusRotationSpeed (optional)
    Percentage 0-100
  • setRotationSpeed (optional)
    Percentage 0-100
  • statusRotationDirection (optional)
    0 = CLOCKWISE, 1 = COUNTER_CLOCKWISE
  • setRotationDirection (optional)
    0 = CLOCKWISE, 1 = COUNTER_CLOCKWISE

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • rotationSpeedFactor (optional, default: 1)

Faucet

topic

  • setActive
  • statusActive (optional)
  • statusFault (optional)

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • faultTrue (optional, default: true)
  • invertFault (optional, default: false)

FilterMaintenance

topic

  • statusFilterChangeIndication
  • statusFilterLifeLevel (optional)
    Percentage 0-100
  • setResetFilterIndication (optional)

payload

GarageDoorOpener

topic

  • setDoor
  • statusDoor (optional)
    0 = OPEN, 1 = CLOSED; 2 = OPENING, 3 = CLOSING, 4 = STOPPED
  • statusObstruction (optional)
  • setLock (optional)
  • statusLock (optional)

payload

  • doorClosed (optional)
  • doorOpening (optional)
  • doorClosing (optional)
  • doorStopped (optional)
  • onObstructionDetected (optional)
  • lockUnsecured (optional)
  • lockSecured (optional)

HeaterCooler

topic

  • statusActive
  • setActive
  • statusCurrentTemperature
  • statusCurrentHeaterCoolerState
    0 = INACTIVE, 1 = IDLE, 2 = HEATING, 3 = COOLING
  • statusTargetHeaterCoolerState
    0 = AUTO, 1 = HEAT, 2 = COOL
  • setTargetHeaterCoolerState
    0 = AUTO, 1 = HEAT, 2 = COOL
  • statusLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • setLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • statusSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • setLockSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • statusRotationSpeed (optional)
    Percentage 0-100
  • setRotationSpeed (optional)
    Percentage 0-100
  • statusCoolingThresholdTemperature (optional)
  • setCoolingThresholdTemperature (optional)
  • statusHeatingThresholdTemperature (optional)
  • setHeatingThresholdTemperature (optional)

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • rotationSpeedFactor (optional, default: 1)

config

  • TemperatureDisplayUnits
    0 = CELSIUS, 1 = FAHRENHEIT

HumidifierDehumidifier

topic

  • statusActive
  • setActive
  • statusCurrentTemperature
  • statusWaterLevel
    Percentage 0-100
  • statusCurrentHumidifierDehumidifierState
    0 = INACTIVE, 1 = IDLE, 2 = HUMIDIFYING, 3 = DEHUMIDIFYING
  • statusTargetHumidifierDehumidifierState
    0 = HUMIDIFIER_OR_DEHUMIDIFIER, 1 = HUMIDIFIER, 2 = DEHUMIDIFIER
  • setTargetHumidifierDehumidifierState
    0 = HUMIDIFIER_OR_DEHUMIDIFIER, 1 = HUMIDIFIER, 2 = DEHUMIDIFIER
  • statusLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • setLockPhysicalControls (optional)
    0 = CONTROL_LOCK_DISABLED, 1 = CONTROL_LOCK_ENABLED
  • statusSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • setLockSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • statusRotationSpeed (optional)
    Percentage 0-100
  • setRotationSpeed (optional)
    Percentage 0-100
  • statusRelativeHumidityDehumidifierThreshold (optional)
  • setRelativeHumidityDehumidifierThreshold (optional)
  • statusRelativeHumidityHumidifierThreshold (optional)
  • setRelativeHumidityHumidifierThreshold (optional)

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • rotationSpeedFactor (optional, default: 1)
  • waterLevelFactor (optional, default: 1)

HumiditySensor

topic

  • statusHumidity
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

IrrigationSystem

topic

  • setActive
  • statusActive
  • statusFault (optional)
  • statusInUse
  • statusRemainingDuration
  • statusProgramMode

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • faultTrue (optional, default: true)
  • invertFault (optional, default: false)
  • inUseTrue (optional, default: true)

LeakSensor

topic

  • statusLeakDetected
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onLeakDetected
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

Lightbulb

topic

  • setOn
  • statusOn (optional)
  • setBrightness (optional)
  • statusBrightness (optional)
  • setHue (optional)
  • statusHue (optional)
  • setSaturation (optional)
  • statusSaturation (optional)
  • setColorTemperature (optional)
  • statusColorTemperature (optional)
  • statusRGB (optional)
  • setRGB (optional)

payload

  • onTrue
  • onFalse
  • brightnessFactor (optional, default: 1)
  • hueFactor (optional, default: 1)
  • saturationFactor (optional, default: 1)

LightSensor

topic

  • statusAmbientLightLevel
    0.0001 - 100000
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • ambientLightLevelFactor (optional, default: 1)
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

LockManagement

topic

  • setLockControlPoint
  • statusVersion
  • statusVersion (optional)
  • statusLogs (optional)
  • setAudioFeedback (optional)
  • statusAudioFeedback (optional)
  • setLockManagementAutoSecurityTimeout (optional)
    Seconds
  • statusLockManagementAutoSecurityTimeout (optional)
    Seconds
  • setAdministratorOnlyAccess (optional)
  • statusAdministratorOnlyAccess (optional)
  • statusLockLastKnownAction (optional)
    0 = SECURED_PHYSICALLY_INTERIOR, 1 = UNSECURED_PHYSICALLY_INTERIOR, 2 = SECURED_PHYSICALLY_EXTERIOR, 3 = UNSECURED_PHYSICALLY_EXTERIOR, 4 = SECURED_BY_KEYPAD, 5 = UNSECURED_BY_KEYPAD, 6 = SECURED_REMOTELY, 7 = UNSECURED_REMOTELY, 8 = SECURED_BY_AUTO_SECURE_TIMEOUT
  • statusCurrentDoorState (optional)
    0 = OPEN, 1 = CLOSED; 2 = OPENING, 3 = CLOSING, 4 = STOPPED
  • statusMotionDetected (optional)

payload

  • doorClosed (optional)
  • doorOpening (optional)
  • doorClosing (optional)
  • doorStopped (optional)

LockMechanism

topic

  • setLock
  • statusLock (optional)

payload

  • lockSecured
  • lockUnsecured
  • lockJammed (optional)
  • lockUnknown (optional)

Microphone

topic

  • setMute
  • statusMute (optional)
  • setVolume (optional)
  • statusVolume (optional)

payload

  • muteTrue
  • muteFalse
  • volumeFactor (optional, default: 1)

MotionSensor

topic

  • statusMotionDetected
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onMotionDetected
  • onLowBattery (optional)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

OccupancySensor

topic

  • statusOccupancyDetected
  • statusLowBattery (optional)

payload

  • onOccupancyDetected
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)

Outlet

topic

  • setOn
  • statusOn (optional)
  • statusOutletInUse

payload

  • onFalse
  • onTrue
  • onOutletInUse

SecuritySystem

topic

  • setSecuritySystemTargetState
    0 = STAY_ARM, 1 = AWAY_ARM, 2 = NIGHT_ARM, 3 = DISARM
  • statusSecuritySystemCurrentState (optional)
    0 = STAY_ARM, 1 = AWAY_ARM, 2 = NIGHT_ARM, 3 = DISARMED, 4 = ALARM_TRIGGERED
  • statusSecuritySystemAlarmType (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

Slat

topic

  • statusCurrentSlatState
    0 = FIXED, 1 = JAMMED, 2 = SWINGING
  • statusCurrentTiltAngle (optional)
  • statusTargetTiltAngle (optional)
  • setTargetTiltAngle (optional)
  • statusSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED
  • setSwingMode (optional)
    0 = SWING_DISABLED, 1 = SWING_ENABLED

payload

config

  • SlatType
    0 = HORIZONTAL, 1 = VERTICAL

SmokeSensor

topic

  • statusSmokeDetected
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • onSmokeDetected
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • onFault (optional)
  • invertFault (optional, default: false)

Speaker

topic

  • setMute
  • statusMute (optional)
  • setVolume (optional)
  • statusVolume (optional)

payload

  • muteTrue
  • muteFalse
  • volumeFactor (default: 1)

StatelessProgrammableSwitch

topic

  • statusEvent
    0 = SINGLE_PRESS, 1 = DOUBLE_PRESS, 2 = LONG_PRESS

payload

Switch

topic

  • setOn
  • statusOn (optional)

payload

  • onFalse
  • onTrue

TemperatureSensor

topic

  • statusTemperature
  • statusLowBattery (optional)
  • statusTampered (optional)
  • statusActive (optional)
  • statusFault (optional)

payload

  • fahrenheit (default: false)
    Set to true if your sensor publishes values in degree fahrenheit
  • onLowBattery (optional)
  • invertLowBattery (optional, default: false)
  • onTampered (optional)
  • invertTampered (optional, default: false)
  • onActive (optional)
  • invertActive (optional, default: false)
  • onFault (optional)
  • invertFault (optional, default: false)

Thermostat

topic

  • setTargetTemperature
  • statusTargetTemperature (optional)
  • statusCurrentTemperature
  • setTargetHeatingCoolingState (optional)
    0 = off, 1 = heat, 2 = cool
  • statusTargetHeatingCoolingState (optional)
    0 = off, 1 = heat, 2 = cool
  • statusCurrentHeatingCoolingState (optional)
    0 = off, 1 = heat, 2 = cool
  • setTargetRelativeHumidity (optional)
  • statusTargetRelativeHumidity (optional)
  • statusCurrentRelativeHumidity (optional)
  • setCoolingThresholdTemperature (optional)
  • statusCoolingThresholdTemperature (optional)
  • setHeatingThresholdTemperature (optional)
  • statusHeatingThresholdTemperature (optional)

payload

config

  • TemperatureDisplayUnits
    0 = CELSIUS, 1 = FAHRENHEIT

Valve

topic

  • setActive
  • statusActive
  • statusFault (optional)
  • statusInUse
  • statusRemainingDuration (optional)
  • setDuration (optional)

payload

  • activeTrue (optional, default: true)
  • invertActive (optional, default: false)
  • faultTrue (optional, default: true)
  • invertFault (optional, default: false)
  • inUseTrue (optional, default: true)

config

  • ValveType (optional, default: 0)
    0 = GENERIC_VALVE, 1 = IRRIGATION, 2 = SHOWER_HEAD, 3 = WATER_FAUCET

Window

topic

  • setTargetPosition
  • statusTargetPosition (optional)
  • statusCurrentPosition (optional)
  • statusPositionState (optional)
  • statusObstruction (optional)

payload

  • targetPositionFactor (optional, default: 1)
  • currentPositionFactor (optional, default: 1)
  • positionStatusDecreasing (optional)
  • positionStatusIncreasing (optional)
  • onObstructionDetected (optional)

WindowCovering

topic

  • setTargetPosition
  • statusTargetPosition (optional)
  • statusCurrentPosition (optional)
  • statusPositionState (optional)
  • statusTargetHorizontalTiltAngle (optional)
  • setTargetHorizontalTiltAngle (optional)
  • statusTargetVerticalTiltAngle (optional)
  • setTargetVerticalTiltAngle (optional)
  • statusCurrentHorizontalTiltAngle (optional)
  • statusCurrentVerticalTiltAngle (optional)

payload

  • targetPositionFactor (optional, default: 1)
  • currentPositionFactor (optional, default: 1)
  • positionStatusDecreasing (optional)
  • positionStatusIncreasing (optional)

License

MIT © Sebastian Raff and homekit2mqtt contributors

homekit2mqtt's People

Contributors

davea avatar ddrd avatar edjopato avatar hobbyquaker avatar m17design avatar mattsheffiel avatar michmich avatar sillyfrog avatar tedstriker avatar tvillingett avatar zino4u avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homekit2mqtt's Issues

Does mosquitto need to install before below command?

Hi awesome maker (Sebastian Raff),

Does mosquitto need to install before below command?
sudo apt-get install libavahi-compat-libdnssd-dev
sudo npm install -g homekit2mqtt --unsafe-perm
homekit2mqtt -v debug

Before sudo npm install -g homekit2mqtt --unsafe-perm
I did

sudo apt-get install libmosquitto-dev
sudo apt-get install mosquitto mosquitto-clients
sudo vi /etc/mosquitto/mosquitto.conf
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
allow_anonymous false
password_file /etc/mosquitto/pwfile
listener 1883
root@raspberrypi:/home/pi# sudo mosquitto_passwd -c /etc/mosquitto/pwfile pi
Password: password
Reenter password: password

sudo reboot

and

mosquitto_sub -d -u pi -P password -t "Nodemcu/Control_R_LED"
mosquitto_pub -d -u pi -P password -t "Nodemcu/Control_R_LED" -m "OFF"

is work

But

root@raspberrypi:/usr/lib/node_modules/homekit2mqtt# homekit2mqtt -v debug -m /usr/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json -u "tcp://127.0.0.1:1883"
*** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs>
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister>
2017-06-22 07:42:06.935 <info>  homekit2mqtt 0.6.9 starting
2017-06-22 07:42:06.955 <info>  mqtt trying to connect tcp://127.0.0.1:**1883**
2017-06-22 07:42:07.436 <info>  using hap-nodejs version 0.4.25
2017-06-22 07:42:07.485 <info>  loading HomeKit to MQTT mapping file /usr/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2017-06-22 07:42:07.494 <debug> loading accessories/Thermostat.js
2017-06-22 07:42:07.504 <debug> addBridgedAccessory Thermostat Thermostat1
2017-06-22 07:42:07.539 <debug> mqtt subscribe Thermostat1/status/CurrentTemperature
2017-06-22 07:42:07.548 <debug> mqtt subscribe Thermostat1/status/TargetTemperature
2017-06-22 07:42:07.551 <debug> mqtt subscribe Thermostat1/status/CurrentHumidity
2017-06-22 07:42:07.564 <debug> loading accessories/WindowCovering.js
2017-06-22 07:42:07.570 <debug> addBridgedAccessory WindowCovering Blind
2017-06-22 07:42:07.588 <debug> mqtt subscribe WindowCovering1/status/TargetPosition
2017-06-22 07:42:07.593 <debug> mqtt subscribe WindowCovering1/status/CurrentPosition
2017-06-22 07:42:07.594 <debug> mqtt subscribe WindowCovering1/status/PositionStatus
2017-06-22 07:42:07.599 <debug> loading accessories/Lightbulb.js
2017-06-22 07:42:07.607 <debug> addBridgedAccessory Lightbulb Licht Garten
2017-06-22 07:42:07.619 <debug> mqtt subscribe Lightbulb1/status
2017-06-22 07:42:07.623 <debug> addBridgedAccessory Lightbulb Lightbulb2
2017-06-22 07:42:07.629 <debug> mqtt subscribe Lightbulb2/status
2017-06-22 07:42:07.631 <debug> mqtt subscribe Lightbulb2/status/Brightness
2017-06-22 07:42:07.633 <debug> addBridgedAccessory Lightbulb Lightbulb3
2017-06-22 07:42:07.635 <debug> mqtt subscribe Lightbulb3/status
2017-06-22 07:42:07.636 <debug> mqtt subscribe Lightbulb3/status/Brightness
2017-06-22 07:42:07.638 <debug> mqtt subscribe Lightbulb3/status/Hue
2017-06-22 07:42:07.639 <debug> mqtt subscribe Lightbulb3/status/Saturation
2017-06-22 07:42:07.641 <debug> loading accessories/Switch.js
2017-06-22 07:42:07.647 <debug> addBridgedAccessory Switch Steckdose Fernseher
2017-06-22 07:42:07.655 <debug> mqtt subscribe Switch/status
2017-06-22 07:42:07.657 <debug> loading accessories/MotionSensor.js
2017-06-22 07:42:07.664 <debug> addBridgedAccessory MotionSensor MotionSensor
2017-06-22 07:42:07.675 <debug> mqtt subscribe MotionSensor/status
2017-06-22 07:42:07.678 <debug> loading accessories/ContactSensor.js
2017-06-22 07:42:07.684 <debug> addBridgedAccessory ContactSensor ContactSensor
2017-06-22 07:42:07.695 <debug> mqtt subscribe ContactSensor/status
2017-06-22 07:42:07.698 <debug> mqtt subscribe ContactSensor/status/LowBattery
2017-06-22 07:42:07.700 <debug> loading accessories/LockMechanism.js
2017-06-22 07:42:07.708 <debug> addBridgedAccessory LockMechanism LockMechanism
2017-06-22 07:42:07.717 <debug> mqtt subscribe LockMechanism/status
2017-06-22 07:42:07.720 <debug> loading accessories/TemperatureSensor.js
2017-06-22 07:42:07.727 <debug> addBridgedAccessory TemperatureSensor TemperatureSensor
2017-06-22 07:42:07.732 <debug> mqtt subscribe TemperatureSensor/Temperature
2017-06-22 07:42:07.737 <debug> loading accessories/LightSensor.js
2017-06-22 07:42:07.742 <debug> addBridgedAccessory LightSensor LightSensor
2017-06-22 07:42:07.746 <debug> mqtt subscribe LightSensor/Brightness
2017-06-22 07:42:07.753 <info>  hap created 11 Accessories
2017-06-22 07:42:07.755 <info>  hap publishing bridge "MQTT Bridge" username=CC:22:3D:E3:CE:F6 port=1883 pincode=031-45-154
events.js:163
      throw er; // Unhandled 'error' event
      ^

**Error: listen EADDRINUSE :::1883**
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at Server.setupListenHandle [as _listen2] (net.js:1259:14)
    at listenInCluster (net.js:1307:12)
    at Server.listen (net.js:1406:7)
    at EventedHTTPServer.listen (/usr/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/util/eventedhttp.js:60:19)
    at HAPServer.listen (/usr/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/HAPServer.js:158:20)
    at Bridge.Accessory.publish (/usr/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/Accessory.js:509:16)
    at Object.<anonymous> (/usr/lib/node_modules/homekit2mqtt/index.js:195:8)
    at Module._compile (module.js:571:32)
root@raspberrypi:/usr/lib/node_modules/homekit2mqtt#

Thanks.

Cannot find accessory on either mac server or raspberry pi

I have installed the latest version and tried it on both a mac and a raspberry pi, but neither shows up when trying to pair with the phone.

I'm my latest try, I started it with this command:

sudo homekit2mqtt -m /usr/local/lib/node_modules/homekit2mqtt/opt/mqtt-smarthome/hekit2mqtt.json -u 'mqtt://thethingbox.local' -a '22:2E:E3:DE:F8'

(I could not find where the default location of the json file should be, so I put it there)

I starts ok, but cannot find it from the iphone.

2016-01-05 11:43:15.001 <info>  homekit2mqtt 0.3.0 starting
2016-01-05 11:43:15.145 <info>  loading HomeKit to MQTT mapping file
2016-01-05 11:43:15.147 <info>  mqtt trying to connect mqtt://thethingbox.local
2016-01-05 11:43:15.161 <info>  Starting HAP-NodeJS 0.0.7
2016-01-05 11:43:15.272 <info>  hap Created 5 Accessories
2016-01-05 11:43:15.272 <info>  hap Publishing Bridge "MQTT Bridge" username=22:2E:E3:DE:F8 port=51826 pincode=031-45-154
2016-01-05 11:43:15.290 <info>  hap Bridge listening on port 51826
2016-01-05 11:43:15.303 <info>  mqtt connected mqtt://thethingbox.local

My configuration file is:

homekit2mqtt.json
{
  "vp//Värmepump Rum": {
    "service": "Thermostat",
    "name": "Golvvärme",
    "topic": {
      "setTargetTemperature": "vp/set/rumstemp börvärde/SETPOINT",
      "statusTargetTemperature": "vp/status/rumstemp börvärde/SETPOINT",
      "statusCurrentTemperature": "vp/status/rumstemp ärvärde/TEMPERATURE"
    },
    "payload": {

    },
    "config": {
      "TemperatureDisplayUnits": 0
    },
    "manufacturer": "Comfortzone",
    "model": "CE50"
  },
  "vv//Värmepump VV": {
    "service": "Thermostat",
    "name": "Varmvatten",
    "topic": {
      "setTargetTemperature": "vv/set/vvtemp börvärde/SETPOINT",
      "statusTargetTemperature": "vv/status/vvtemp börvärde/SETPOINT",
      "statusCurrentTemperature": "vv/status/vvtemp ärvärde/TEMPERATURE"
    },
    "payload": {

    },
    "config": {
      "TemperatureDisplayUnits": 0
    },
    "manufacturer": "Comfortzone",
    "model": "CE50"
  }
    ,
    "mk//MK Ytterdörr": {
    "service" : "ContactSensor",
    "name" : "Ytterdörr",
    "topic": {
      "statusContactSensorState": "mk/status/Ytterdorr/STATUS"
    },
    "payload": {
        "onContactDetected" : "door closed"
    },
    "manufacturer": "Siemens",
    "model":        "MK 240"
  }
    ,
    "mk//MK Groventré": {
    "service" : "ContactSensor",
    "name" : "Groventré",
    "topic": {
      "statusContactSensorState": "mk/status/Groventré/STATUS"
    },
    "payload": {
        "onContactDetected" : "door closed"
    },
    "manufacturer": "Siemens",
    "model":        "MK 240"
  }
    ,
    "mk//MK Altan": {
    "service" : "ContactSensor",
    "name" : "Altan",
    "topic": {
      "statusContactSensorState": "mk/status/Altan/STATUS"
    },
    "payload": {
        "onContactDetected" : "door closed"
    },
    "manufacturer": "Siemens",
    "model":        "MK 240"
  }
}

SyntaxError: Block-scoped declarations

Note: Fisrt time using homekit2mqtt. (Currently using homebridge and mosquitto, they don't conflict right?)

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 8.0 (jessie)
Release:	8.0
Codename:	jessie

$ nodejs -v
v7.10.1
$ node -v
v4.3.2
$ npm -v
5.3.0

$ sudo homekit2mqtt -v debug
/usr/local/lib/node_modules/homekit2mqtt/index.js:24
let mqttConnected;
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:134:18)
    at node.js:962:3

Adding support for StatusTampered, battery level, and others

I noticed there are comments in accessories/ContactSensor.js and others about adding support for StatusActive, StatusFault, and StatusTampered characteristics. Does this just mean additional if statements and appropriate code need to be added such as how statusLowBattery is implemented or does additional work need to be done to implement these?

Also, would it be possible at this point to add support for battery level (percentage) being reported? I played around with it but it seems that maybe support has to be added elsewhere in the code for homekit2mqtt before that can be added. This is my first time working with anything in NodeJS so I apologize in advance if these questions have obvious answers.

Temperature Sensor

Hello and thanks for project!

For some reason temperature sensor displays wrong value. F.e openHAB reports 65.60 to MQTT topic but HomeKit displays 150. Any ideas ?

Adding more sensor types

I would like to add sensors like energy, water usage etc. Can I have any pointers on how to accomplish that? Does HAP-NodeJS also needs to be changed?

mqtt.on "message" always returns "undefined"

Hello,

I'm a complete newbie when it comes to JavaScript, so feel free to tell me I'm holding it wrong :)

While trying to get a fake switch to work, I kept encountering an issue where no matter what I published to the MQTT server, homekit2mqtt would always see it as "undefined":
screen shot 2016-06-02 at 7 20 21 am

Diving in to the code, noticed 46 of index.js says:

state = JSON.parse(payload).val;

When I changed that to:

state = JSON.parse(payload);

It started working.

screen shot 2016-06-02 at 7 22 59 am

Is this a bug in the code, or am I doing something wrong?

Sprinkler and other new devices

Would it be possible to add in support for the new iOS 11 devices such a sprinkler and faucet? I'm currently using a switch for my sprinkler, and that would be good to use this new feature.

Thanks!

PS: I'm loving the new web interface!

Unable to install on Raspberry Pi.

Awesome package! Works wonderfull on my Mac. Unfortunately, I'm unable to install it on my mac

sudo npm install -g homekit2mqtt
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/usr/local/lib/node_modules/homekit2mqtt/node_modules/mdns/build'
  CXX(target) Release/obj.target/dns_sd_bindings/src/dns_sd.o
In file included from ../src/dns_sd.cpp:1:0:
../src/mdns.hpp:32:20: fatal error: dns_sd.h: No such file or directory
 #include <dns_sd.h>
                    ^
compilation terminated.
dns_sd_bindings.target.mk:142: recipe for target 'Release/obj.target/dns_sd_bindings/src/dns_sd.o' failed
make: *** [Release/obj.target/dns_sd_bindings/src/dns_sd.o] Error 1
make: Leaving directory '/usr/local/lib/node_modules/homekit2mqtt/node_modules/mdns/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 4.1.19-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/homekit2mqtt/node_modules/mdns
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm info lifecycle [email protected]~install: Failed to exec install script
/usr/local/lib
└── (empty)

npm ERR! Linux 4.1.19-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "homekit2mqtt"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mdns package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mdns
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls mdns
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/pi/npm-debug.log
npm ERR! code 1

Any idea?

external script execution

Hello,

I was wondering, is it possible to execute external python scrip in addition to MQTT functionality? Which piece of code to change to perform such action?

"GarageDoor" status on startup

Sorry if I missed something in configuration. GarageDoor sensor reports OPEN when homekit2mqtt restarts. Is there any way to set default to CLOSE ? Same for example with Alarm, on restart it reports HOME, I'll prefer OFF.

Thank you.

Problem with setOn in LightBulb

Problem with LightBulb, this not remember 'setOn', when I set off, close HomeApp and open Light is on and should be off

2017-08-23 03:04:52.769 <debug> < hap set Test Philips On 0
2017-08-23 03:04:52.773 <debug> > mqtt /home/setOn false
2017-08-23 03:05:01.526 <debug> < hap get Test Philips On
2017-08-23 03:05:01.529 <debug> > hap re_get Test Philips On true
{
  "TestPhilips": {
    "id": "TestPhilips",
    "name": "Test Philips",
    "service": "Lightbulb",
    "topic": {
      "setOn": "/home/setOn",
      "setBrightness": "/home/setB",
      "setColorTemperature": "/home/setColor",
      "identify": "test1"
    },
    "payload": {
      "onTrue": true,
      "onFalse": false,
      "brightnessFactor": "",
      "hueFactor": "",
      "saturationFactor": ""
    },
    "config": {}
  }
}

Thermostat targetTemperature prop case

I have noticed that the "targetTemperature" prop for a Thermostat does not work, after a quick look at the code and some playing around, it should be "TargetTemperature" (uppercase T at the start).

I'm not sure the best way to fix it (I think updating the code to allow for "targetTemperature", but wanted to leave that to you as I'm not familiar with the code).

If there is anything I can do, please let me know.

PS: Thanks for this project, it's great and starting to become the core of my (new) home automation - really appreciate it!

Can't connect to local Mosquitto server

Hello,

The Homekit2MQTT bridge will not connect to my local Mosquitto instance. I can sub and pub using the built-in mosquitto commands, but I cannot see anything coming from the homekit2mqtt bridge. Specified URL is "tcp://localhost:1883" but I have also tried "mqtt://127.0.0.1". Any help would be appreciated. Thanks.

Thermostat "No response" in Auto mode

If send topic: "/homekit/tp-mode-stat" payload: "3"
for statusCurrentHeatingCoolingState.
Then Thermostat accessory show "No response" and sometimes MQTT Bridge also show "No response" and stop working.

No debug output
{
	"Therm-tp-van": {
		"service": "Thermostat",
		"name":    "Теплый пол",
		"topic": {
			"setTargetTemperature":     "/homekit/tp-target",
			"statusCurrentTemperature": "/homekit/tp-curr",
			"statusTargetTemperature":  "/homekit/tp-target-stat",
			"setTargetHeatingCoolingState":"/homekit/tp-mode",
			"statusCurrentHeatingCoolingState":"/homekit/tp-mode-stat"
		},
		"config": {
			"TemperatureDisplayUnits": 0
		},
		"manufacturer": "Generic",
		"model": "Thermostat"
	}
}

Speaker "Not Supported" in iOS Home app

Thank you for fixing #35 !

Now the accessory is created (and no crash) but in Home on iOS, it merely shows "Not Supported" for the Speaker.

There's no related logs in homekit2mqtt output.

I'm running iOS 10.3.3. Is this an iOS 11 feature?

I've just implemented just the minimal configuration:

{
  "Speaker": {
    "service": "Speaker",
    "name": "Speaker",
    "topic": {
      "setMute": "home/speaker/mute"
    },
    "payload": {
      "muteTrue": "mute",
      "muteFalse": "unmute"
    }
  }
}

Is there anything useful I can do to debug this?

homekit2mqtt stops working after some hours.

Hi!!

First of all I would like to thank for this wonderful project, it is super easy to implement and for me it works out of the box.
For newbies like me it is great to have things like this.

I just have one issue, for some reason it stops working after some time, usually after some 3-4 hours but it can be more.

I have the system working on a Raspberry Pi 3 B, with raspbian lite on it.
The home automation system is based on Mosquitto, then with Node-Red I create the connections for which I have the web interface (which btw it does not stop working when homekit2mqtt does),
and on top I have the homekit2mqtt.

I am running homekit2mqtt like this:

nohup homekit2mqtt -v debug -m /home/pi/homekit2mqtt/homekit2mqtt.json -s /home/pi/homekit2mqtt/log/ &

When starting to run I get this:
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister

but I read that this is "normal" and should not be a problem.

The homekit data stored with the option -s is:

AccessoryInfo.CC223DE3CEF6.json:
{"displayName":"MQTT Bridge","category":1,"pincode":"031-45-154","signSk":"7347bc40fae798fdddf5de32c3f4ab0fd57db685587f9c4fbe6bb60ca3bf16074006eee32b41181ac9dcbbbbc129234dc0582608c9d41191c938b8bb322eadce","signPk":"4006eee32b41181ac9dcbbbbc129234dc0582608c9d41191c938b8bb322eadce","pairedClients":{"D9A170FC-6839-4D0A-81D0-8ABA4B85A1B4":"3f09529cd86a6766b3726c2c693fbf1d81586f8a52e07673ca92d836cd076422"},"configVersion":2,"configHash":"c53ca047d5cfa8a5f5c32e6fe786f38a21c2de33","setupID":"EJA5","relayEnabled":false,"relayState":2,"relayAccessoryID":"","relayAdminID":"","relayPairedControllers":{},"accessoryBagURL":""}

IdentifierCache.CC223DE3CEF6.json :
{"cache":{"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|nextIID":8,"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|0000003E-0000-1000-8000-0026BB765291|00000014-0000-1000-8000-0026BB765291":2,"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|0000003E-0000-1000-8000-0026BB765291|00000020-0000-1000-8000-0026BB765291":3,"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|0000003E-0000-1000-8000-0026BB765291|00000021-0000-1000-8000-0026BB765291":4,"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|0000003E-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":5,"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|0000003E-0000-1000-8000-0026BB765291|00000030-0000-1000-8000-0026BB765291":6,"fe95ec13-71a8-4e0a-9f2b-9d5bb76c35d6|0000003E-0000-1000-8000-0026BB765291|00000052-0000-1000-8000-0026BB765291":7,"|nextAID":7,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82":2,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|nextIID":11,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|0000003E-0000-1000-8000-0026BB765291|00000014-0000-1000-8000-0026BB765291":2,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|0000003E-0000-1000-8000-0026BB765291|00000020-0000-1000-8000-0026BB765291":3,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|0000003E-0000-1000-8000-0026BB765291|00000021-0000-1000-8000-0026BB765291":4,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|0000003E-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":5,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|0000003E-0000-1000-8000-0026BB765291|00000030-0000-1000-8000-0026BB765291":6,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|0000003E-0000-1000-8000-0026BB765291|00000052-0000-1000-8000-0026BB765291":7,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|00000043-0000-1000-8000-0026BB765291":8,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|00000043-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":9,"16b65a22-d9b8-4ea7-8bf3-dc637ff63a82|00000043-0000-1000-8000-0026BB765291|00000025-0000-1000-8000-0026BB765291":10,"69c0038d-14bc-45ca-90ac-ac5f132fbb14":3,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|nextIID":11,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|0000003E-0000-1000-8000-0026BB765291|00000014-0000-1000-8000-0026BB765291":2,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|0000003E-0000-1000-8000-0026BB765291|00000020-0000-1000-8000-0026BB765291":3,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|0000003E-0000-1000-8000-0026BB765291|00000021-0000-1000-8000-0026BB765291":4,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|0000003E-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":5,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|0000003E-0000-1000-8000-0026BB765291|00000030-0000-1000-8000-0026BB765291":6,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|0000003E-0000-1000-8000-0026BB765291|00000052-0000-1000-8000-0026BB765291":7,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|00000043-0000-1000-8000-0026BB765291":8,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|00000043-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":9,"69c0038d-14bc-45ca-90ac-ac5f132fbb14|00000043-0000-1000-8000-0026BB765291|00000025-0000-1000-8000-0026BB765291":10,"151f3f80-5215-48cf-bc15-01d7887ec58c":4,"151f3f80-5215-48cf-bc15-01d7887ec58c|nextIID":11,"151f3f80-5215-48cf-bc15-01d7887ec58c|0000003E-0000-1000-8000-0026BB765291|00000014-0000-1000-8000-0026BB765291":2,"151f3f80-5215-48cf-bc15-01d7887ec58c|0000003E-0000-1000-8000-0026BB765291|00000020-0000-1000-8000-0026BB765291":3,"151f3f80-5215-48cf-bc15-01d7887ec58c|0000003E-0000-1000-8000-0026BB765291|00000021-0000-1000-8000-0026BB765291":4,"151f3f80-5215-48cf-bc15-01d7887ec58c|0000003E-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":5,"151f3f80-5215-48cf-bc15-01d7887ec58c|0000003E-0000-1000-8000-0026BB765291|00000030-0000-1000-8000-0026BB765291":6,"151f3f80-5215-48cf-bc15-01d7887ec58c|0000003E-0000-1000-8000-0026BB765291|00000052-0000-1000-8000-0026BB765291":7,"151f3f80-5215-48cf-bc15-01d7887ec58c|00000043-0000-1000-8000-0026BB765291":8,"151f3f80-5215-48cf-bc15-01d7887ec58c|00000043-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":9,"151f3f80-5215-48cf-bc15-01d7887ec58c|00000043-0000-1000-8000-0026BB765291|00000025-0000-1000-8000-0026BB765291":10,"33133c42-6220-4ffc-8364-f87a2d68ce80":5,"33133c42-6220-4ffc-8364-f87a2d68ce80|nextIID":10,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000003E-0000-1000-8000-0026BB765291|00000014-0000-1000-8000-0026BB765291":2,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000003E-0000-1000-8000-0026BB765291|00000020-0000-1000-8000-0026BB765291":3,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000003E-0000-1000-8000-0026BB765291|00000021-0000-1000-8000-0026BB765291":4,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000003E-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":5,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000003E-0000-1000-8000-0026BB765291|00000030-0000-1000-8000-0026BB765291":6,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000003E-0000-1000-8000-0026BB765291|00000052-0000-1000-8000-0026BB765291":7,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000008A-0000-1000-8000-0026BB765291":8,"33133c42-6220-4ffc-8364-f87a2d68ce80|0000008A-0000-1000-8000-0026BB765291|00000011-0000-1000-8000-0026BB765291":9,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09":6,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|nextIID":10,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|0000003E-0000-1000-8000-0026BB765291|00000014-0000-1000-8000-0026BB765291":2,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|0000003E-0000-1000-8000-0026BB765291|00000020-0000-1000-8000-0026BB765291":3,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|0000003E-0000-1000-8000-0026BB765291|00000021-0000-1000-8000-0026BB765291":4,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|0000003E-0000-1000-8000-0026BB765291|00000023-0000-1000-8000-0026BB765291":5,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|0000003E-0000-1000-8000-0026BB765291|00000030-0000-1000-8000-0026BB765291":6,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|0000003E-0000-1000-8000-0026BB765291|00000052-0000-1000-8000-0026BB765291":7,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|00000082-0000-1000-8000-0026BB765291":8,"8fa54d0f-6ffc-408a-bcb1-6adc4c384f09|00000082-0000-1000-8000-0026BB765291|00000010-0000-1000-8000-0026BB765291":9}}

Thanks for your help!!

Updating devices when locked takes a long time

When viewing my devices in the action center by swiping from the bottom up it sometimes takes a long time for the devices to update their status, they just sit there "updating". This is sometimes fixed by closing the action center, unlocking the phone and opening the action center again.

Is this something that you also experience or is it just me?

Last but not least, thank you for the great work you have put in this project!

Run in background mode?

Hi,

First of all, thanks for this great code!

I've tried fire homekit2mqtt up via and putty shows:

 sudo homekit2mqtt
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
2017-11-08 16:03:20.374 <info>  homekit2mqtt 0.7.2 starting
2017-11-08 16:03:20.384 <info>  mqtt trying to connect mqtt://127.0.0.1
2017-11-08 16:03:20.595 <info>  using hap-nodejs version 0.4.36
2017-11-08 16:03:20.622 <info>  loading HomeKit to MQTT mapping file /usr/local/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2017-11-08 16:03:20.736 <info>  hap created 10 Accessories
2017-11-08 16:03:20.737 <info>  hap publishing bridge "MQTT Bridge" username=CC:22:3D:E3:CE:F6 port=51826 pincode=031-45-154
2017-11-08 16:03:20.852 <info>  hap Bridge listening on port 51826
2017-11-08 16:03:20.853 <info>  http server listening on port 51888
2017-11-08 16:03:20.882 <info>  mqtt connected mqtt://127.0.0.1

After the last line, there is an empy line but no cursor. In other words, this putty window is now useless but I guess I have to keep it open to keep homekit2mqtt running.

Is there any way of running the program in background mode? I tried the usual '&' sign on the end but to no avail. Sorry if the solution is obvious but I am kind of stuck.

Thank you in advance.

Problem Installing

What could be happening to get this error while installing it?

root@fuscao:/# npm install homekit2mqtt --unsafe-perm

[email protected] install /node_modules/mdns
node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
make: Entering directory '/node_modules/mdns/build'
CXX(target) Release/obj.target/dns_sd_bindings/src/dns_sd.o
In file included from ../src/dns_sd.cpp:1:0:
../src/mdns.hpp:32:20: fatal error: dns_sd.h: Arquivo ou diretório não encontrado
#include <dns_sd.h>
^
compilation terminated.
dns_sd_bindings.target.mk:152: recipe for target 'Release/obj.target/dns_sd_bindings/src/dns_sd.o' failed
make: *** [Release/obj.target/dns_sd_bindings/src/dns_sd.o] Error 1
make: Leaving directory '/node_modules/mdns/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/root/.nvm/versions/node/v7.7.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.16.0-4-amd64
gyp ERR! command "/root/.nvm/versions/node/v7.7.2/bin/node" "/root/.nvm/versions/node/v7.7.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/mdns
gyp ERR! node -v v7.7.2
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/root/.nvm/versions/node/v7.7.2/bin/node" "/root/.nvm/versions/node/v7.7.2/bin/npm" "install" "homekit2mqtt" "--unsafe-perm"
npm ERR! node v7.7.2
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the mdns package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs mdns
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mdns
npm ERR! There is likely additional logging output above.

a bug in Thermostate.js

from line 59, the var state was statically point to 1, this make the homekit always in heating mode.
it should be modified to this:

thermo.getService(Service.Thermostat)
            .getCharacteristic(Characteristic.CurrentHeatingCoolingState)
            .on('get', function (callback) {
                log.debug('< hap get', settings.name, 'CurrentHeatingCoolingState');
                // var state = 1; // hei! this make it always in heating mode。
                // log.debug('> hap re_get', settings.name, 'CurrentHeatingCoolingState', state);
                // callback(null, state);
                log.debug('> hap re_get', settings.name, 'CurrentHeatingCoolingState', mqttStatus[settings.topic.statusCurrentHeatingCoolingState]);
                callback(null, mqttStatus[settings.topic.statusCurrentHeatingCoolingState]);
            });

and then in the item configuration file, should add a topic to replay the currentmode
"statusCurrentHeatingCoolingState": "/sensor1/status/HeatingCoolingState"
something like that.

Cannot run the program (on mac)

Hi,
when I try to install it, after

sudo npm install -g homekit2mqtt

I try to start it with

Anders-Erikssons-Mac-mini:.homebridge anders$ homekit2mqtt
/usr/local/bin/homekit2mqtt: line 1: syntax error near unexpected token `('
/usr/local/bin/homekit2mqtt: line 1: `var pkg = require('./package.json');'

I guess it is something simple but I cannot get it...

Cannot run the last version (0.6.2)

See log:
/usr/bin/homekit2mqtt -v
2016-11-19 21:55:23.808 homekit2mqtt 0.6.2 starting
2016-11-19 21:55:24.414 mqtt trying to connect mqtt://127.0.0.1
2016-11-19 21:55:24.469 using hap-nodejs version 0.4.15
*** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister
2016-11-19 21:55:24.825 loading HomeKit to MQTT mapping file /usr/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
/usr/lib/node_modules/homekit2mqtt/accessories/Thermostat.js:3
var {mqttPub, mqttSub, mqttStatus, log, newAccessory, Service, Characteristic} = iface;
^

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at loadAccessory (/usr/lib/node_modules/homekit2mqtt/index.js:168:28)
at /usr/lib/node_modules/homekit2mqtt/index.js:179:9
at Array.forEach (native)

Paring lost on restart

I have recently upgraded from v0.6.10 to v0.7.2. After upgrading I needed to reconnect my iPhone to homekit2mqtt, I thought this was just a one off but now I have restarted homekit2mqtt again, I've found my iPhone has lost connectivity. Looking at the debug logs does not show any hints as to the issue. I have run a tcpdump and included the relevant parts below, best I can tell is not trusting the phone any more.

POST /pair-verify HTTP/1.1
Host: MQTT\032Bridge._hap._tcp.local
Content-Length: 37
Content-Type: application/pairing+tlv8


HTTP/1.1 403 Forbidden
Date: Sun, 29 Oct 2017 02:34:15 GMT
Connection: keep-alive
Transfer-Encoding: chunked

This is the command I'm using to run homekit2mqtt, the main change from the 0.6.10 is the addition of the --storagedir option:

/usr/bin/homekit2mqtt -v debug --url mqtt://mos.host --mapfile /homekit2mqtt/conf/homekit2mqtt.json --storagedir /homekit2mqtt/persist/

Light Bulb Color issue

Could you please let me how Light bulb should output color value ? Is it RGB format or ?
From what I see right now it is just one number. F.e red outputs just 0. Blue 255.

Can't start on Ubuntu Server 14.04

Hello,
I am trying to use this on Ubuntu Server 14.04. The error node gives me is:

2016-10-17 20:54:51.344 homekit2mqtt 0.4.7 starting
2016-10-17 20:54:51.594 loading HomeKit to MQTT mapping file /usr/local/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2016-10-17 20:54:51.595 mqtt trying to connect mqtt://127.0.0.1
2016-10-17 20:54:51.606 using hap-nodejs version 0.4.11
*** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister

/usr/local/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/util/eventedhttp.js:62
let port = this._tcpServer.address().port;
^^^
SyntaxError: Unexpected strict mode reserved word
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/homekit2mqtt/node_modules/hap-nodejs/lib/HAPServer.js:11:25)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

Example payloads for LockMechanism incorrect (?)

I think i found an error in the example config (or i might have misunderstood something along the way). My lockmechanism worked correctly (opening and closing), but it would always report as being unsecured. Also, in the Home app on iOS, the lock status would just stay at "Locking..." indefinitely.

I had to change the config from this:

"payload": {
      "lockUnsecured": "1",
      "lockSecured": "0"
 }

To this:

"payload": {
      "lockUnsecured": 1,
      "lockSecured": 0
 }

After that my lock reported status correctly.

P.S. Thanks for making this project, it's way cool.

Speaker accessory does not seem to work

I cannot seem to get the Speaker accessory to work. I do note it is not in the example file.

The parameters passed to mqttPub seem different to a working one (Thermostat) in createAccessory. But I know nothing about node so that's just a guess :-)

2017-08-09 18:21:09.140 <info>  homekit2mqtt 0.6.11 starting
2017-08-09 18:21:09.142 <info>  mqtt trying to connect mqtt://127.0.0.1
2017-08-09 18:21:09.166 <info>  using hap-nodejs version 0.4.27
2017-08-09 18:21:09.169 <info>  loading HomeKit to MQTT mapping file /home/justin/gurrs-homekit2mqtt.json
/usr/lib/node_modules/homekit2mqtt/node_modules/mqtt/lib/client.js:416
  var resubscribe = obj.resubscribe
                       ^

TypeError: Cannot read property 'resubscribe' of undefined
    at MqttClient.subscribe (/usr/lib/node_modules/homekit2mqtt/node_modules/mqtt/lib/client.js:416:24)
    at mqttSub (/usr/lib/node_modules/homekit2mqtt/index.js:93:18)
    at Object.createAccessory_Speaker [as Speaker] (/usr/lib/node_modules/homekit2mqtt/accessories/Speaker.js:20:9)
    at Object.keys.forEach.id (/usr/lib/node_modules/homekit2mqtt/index.js:189:58)
    at Array.forEach (native)
    at Object.<anonymous> (/usr/lib/node_modules/homekit2mqtt/index.js:182:22)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
 {
  "Speaker": {
    "service": "Speaker",
    "name": "Speaker",
    "topic": {
      "setMute": "home/speaker/mute"
    },
    "payload": {
      "muteTrue": "mute",
      "muteFalse": "unmute"
    }
  }
}

Cheers

connecting to existing mqtt server [assistance required]

hi. probably super simple but please can i ask where / how i configure my current mqtt server, port, username and password? i've read, reread and looked through all the files but can't find anything that looks configurable for me. cheers, don

MQTT disconnecting when trying to publish.

I trying to open and close the garage door from homekit app but it looks like the MQTT server is not receiving the message.

homekit2mqtt.json configuration:
{
"GarageDoorOpener": {
"service": "GarageDoorOpener",
"name": "Garage Door",
"topic": {
"setDoor": "GarageDoor/Set",
"statusDoor": "GarageDoor/Status"
},
"payload": {
"doorOpen": "OpenGarageDoor",
"doorClosed": "CloseGarageDoor"
},
"manufacturer": "Generic",
"model": "Generic"
}
}

****Logs on server running homekit2mqtt and homebridge: ****

pi@raspberrypi:~ $ sudo homekit2mqtt -v debug
2016-11-06 12:19:50.855 homekit2mqtt 0.5.2 starting
2016-11-06 12:19:51.974 loading HomeKit to MQTT mapping file /usr/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2016-11-06 12:19:51.981 mqtt trying to connect mqtt://192.168.0.10
2016-11-06 12:19:52.069 using hap-nodejs version 0.4.13
*** WARNING *** The program 'nodejs' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs
*** WARNING *** The program 'nodejs' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=nodejs&f=DNSServiceRegister
2016-11-06 12:19:52.742 addBridgedAccessory GarageDoorOpener Garage Door
2016-11-06 12:19:52.766 mqtt subscribe GarageDoor/Status
2016-11-06 12:19:52.785 hap created 1 Accessories
2016-11-06 12:19:52.791 hap publishing bridge "MQTT Bridge" username=AC:A2:AD:A3:AE:A6 port=51832 pincode=031-45-154
2016-11-06 12:19:52.928 hap Bridge listening on port 51832
2016-11-06 12:19:52.981 mqtt connected mqtt://192.168.0.10
2016-11-06 12:20:35.377 < hap get Garage Door CurrentDoorState
2016-11-06 12:20:35.378 > hap re_get Garage Door CurrentDoorState.OPEN
2016-11-06 12:20:35.382 < hap get Garage Door ObstructionDetected
2016-11-06 12:20:35.383 > hap re_get Garage Door ObstructionDetected true
2016-11-06 12:20:35.939 < hap set Garage Door TargetDoorState 1
2016-11-06 12:20:35.939 > mqtt publish GarageDoor/Set CloseGarageDoor
2016-11-06 12:20:35.949 mqtt closed mqtt://192.168.0.10
2016-11-06 12:20:37.008 mqtt connected mqtt://192.168.0.10
2016-11-06 12:20:47.944 < hap set Garage Door TargetDoorState 0
2016-11-06 12:20:47.945 > mqtt publish GarageDoor/Set OpenGarageDoor
2016-11-06 12:20:47.947 mqtt closed mqtt://192.168.0.10
2016-11-06 12:20:48.960 mqtt connected mqtt://192.168.0.10

**** Logs on MQTT server: ****

1478452943: New connection from 192.168.0.19 on port 1883.
1478452943: New client connected from 192.168.0.19 as mqttjs_c4826491 (c1, k60).
1478452943: Sending CONNACK to mqttjs_c4826491 (0, 0)
1478452943: Received SUBSCRIBE from mqttjs_c4826491
1478452943: GarageDoor/Status (QoS 0)
1478452943: mqttjs_c4826491 0 GarageDoor/Status
1478452943: Sending SUBACK to mqttjs_c4826491
1478452943: Received PUBLISH from mqttjs_c4826491 (d0, q0, r1, m0, 'homekit/connected', ... (1 bytes))
1478452987: New connection from 192.168.0.19 on port 1883.
1478452987: Client mqttjs_c4826491 already connected, closing old connection.
1478452987: Client mqttjs_c4826491 disconnected.
1478452987: New client connected from 192.168.0.19 as mqttjs_c4826491 (c1, k60).
1478452987: Sending CONNACK to mqttjs_c4826491 (0, 0)
1478452987: Received SUBSCRIBE from mqttjs_c4826491
1478452987: GarageDoor/Status (QoS 0)
1478452987: mqttjs_c4826491 0 GarageDoor/Status
1478452987: Sending SUBACK to mqttjs_c4826491
1478452987: Received PUBLISH from mqttjs_c4826491 (d0, q0, r1, m0, 'homekit/connected', ... (1 bytes))
1478452999: New connection from 192.168.0.19 on port 1883.
1478452999: Client mqttjs_c4826491 already connected, closing old connection.
1478452999: Client mqttjs_c4826491 disconnected.
1478452999: New client connected from 192.168.0.19 as mqttjs_c4826491 (c1, k60).
1478452999: Sending CONNACK to mqttjs_c4826491 (0, 0)
1478452999: Received SUBSCRIBE from mqttjs_c4826491
1478452999: GarageDoor/Status (QoS 0)
1478452999: mqttjs_c4826491 0 GarageDoor/Status
1478452999: Sending SUBACK to mqttjs_c4826491
1478452999: Received PUBLISH from mqttjs_c4826491 (d0, q0, r1, m0, 'homekit/connected', ... (1 bytes))

GarageDoorOpener - Siri Issue

I have the GarageDoorOpener working fine within the Home App, however Siri continually reports that the Garage Door is "opening" when asked the status. I am using Mqtt to publish the status which shows correctly in the App, but somehow Siri is not aware.

I'm a hardware guy and a bit of a software 'hack', but here is what I have for a configuration. Any ideas?

Thanks

"GarageDoorOpener": {
"service": "GarageDoorOpener",
"name": "North Garage Door",
"topic": {
"setDoor": "GarageDoor/set",
"statusDoor": "GarageDoor/status"
},
"payload": {
"doorOpen": 1,
"doorClosed": 0
},
"manufacturer": "Generic",
"model": "Generic"

Stops working after some minutes / Ubiquiti UniFi Switch US-16-XG => Solved

Hi,

I installed homekit2mqtt with Mosquitto on Ubuntu 17.0 / Node.js 6. Everything worked for approx. 5 minutes. Then all devices in the home app showed "connection lost". After restarting homekit2mqtt the problem occurred again after several minutes. I tried this with all demo devices and also with only one demo device.

I tried again on a fresh Ubuntu 17.1/ Node.js 8 installation. Same result. I started with the "debug" option but no errors where shown.

After this I installed it on my MacBook Pro (High Sierra, Node.js 8) and everything worked perfectly.

How can I solve this problem?

Best regards
Christoph

Outlet status doesn't update

Here is debug log :

2017-07-30 09:59:17.746 <debug> < mqtt /myhome/loutlet/state 1
2017-07-30 09:59:17.746 <debug> > hap set Living Room Outlet OutletInUse false
2017-07-30 09:59:24.003 <debug> < mqtt /myhome/loutlet/state 0
2017-07-30 09:59:24.003 <debug> > hap set Living Room Outlet OutletInUse false

If I am not making mistake state=1 should set OutletInUse to true.

Optional lock not appearing in GarageDoorOpener accessory

I have setup a home gate using the GarageDoorOpener accessory. I defined lock characteristics, but the Lock characteristics do not appear on my iPhone Home app for the accessory. The open/close works fine.

2017-09-27 20:56:54.032 <info>  homekit2mqtt 0.7.2 starting
2017-09-27 20:56:54.050 <info>  mqtt trying to connect mqtt://127.0.0.1
2017-09-27 20:56:54.481 <info>  using hap-nodejs version 0.4.32
2017-09-27 20:56:54.534 <info>  loading HomeKit to MQTT mapping file /home/pi/homekit2mqtt.json
.
2017-09-27 20:56:54.578 <debug> loading accessories/GarageDoorOpener.js
2017-09-27 20:56:54.586 <debug> addBridgedAccessory GarageDoorOpener Gate
2017-09-27 20:56:54.601 <debug> mqtt subscribe Gate/statusGate
2017-09-27 20:56:54.603 <debug> mqtt subscribe Gate/statusObstruction
2017-09-27 20:56:54.606 <debug> mqtt subscribe Gate/statusLock
.
2017-09-27 20:56:54.994 <debug> < mqtt gate/CurrentGateState 1
2017-09-27 20:56:54.995 <debug> < mqtt gate/DEBUG gate/TargetGateState
.....

json file:

  "Gate": {
    "id": "Gate",
    "name": "Gate",
    "service": "GarageDoorOpener",
    "topic": {
        "statusDoor": "Gate/statusGate",
        "setDoor": "Gate/setGate",
        "statusLock": "Gate/statusLock",
        "statusObstruction": "Gate/statusObstruction",
        "setLock": "Gate/setLock"
    },
    "payload": {
        "doorOpen":0 ,
        "doorClosed":1 ,
        "doorOpening":2, 
        "doorClosing":3,
        "doorStopped":4,
        "onObstructionDetected":1,
        "lockUnsecured":0,
        "lockSecured":1
    }
  },

Accessory state is not checked upon start

I'm trying to replace a homebridge setup that uses homebridge-mqtt-tasmota, and even though I can toggle outlet power, the HomeKit devices do not mirror the actual device states no matter what I do.

I initially suspected this was due to the requirement for the {"val": ... payload format (which I cannot customise without re-flashing all the devices), but I may be mis-understanding the topic structure.

The solution I'm using is very clear on the topic meaning, and looks like this:

"topics": {
	"statusGet": "stat/sonoff/RESULT",
	"statusSet": "cmnd/sonoff/POWER",
	"stateGet": "tele/sonoff/STATE"
},
"onValue": "ON",
"offValue": "OFF",
	
"activityTopic": "tele/sonoff/LWT",
"activityParameter": "Online",
    
"startCmd": "cmnd/sonoff/TelePeriod",
"startParameter": "60",

I tried using the statusGet topic as input to statusOn, but the semantics seem to be different, and the outlet code does not seem to issue a status request, only listen passively for a message in the right topic.

Any hint as to how to configure homekit2mqtt for this kind of setup?

Outlet accessory error

Hello,
I noticed that when I added an Oulet accessory the terminal reported:
Error: Cannot add a Service with the same UUID '00000047-0000-1000-8000-0026BB765291' as another Service in this Accessory without also defining a unique 'subtype' property.

Add support for single and long press with stateless programmable switch

At present it seems that the stateless programmable switch is hard coded to send a 1 which represents a double press. This should also support 0 for single press, and 2 for long press.

HAP-NodeJS has these predefined as with others characteristics.

Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS = 0;
Characteristic.ProgrammableSwitchEvent.DOUBLE_PRESS = 1;
Characteristic.ProgrammableSwitchEvent.LONG_PRESS = 2;

ContactSensor not changing state

I cannot get this to work, is the contactsensor function tested?
I try to send mk/status/Ytterdorr/STATUS with { "var" : "door close" } and { "var" : "door open" }

snippet from the homekit2mqtt.json

    "mk//MK Ytterdörr": {
    "service" : "ContactSensor",
    "name" : "Ytterdörr",
    "topic": {
      "statusContactSensorState": "mk/status/Ytterdorr/STATUS"
    },
    "payload": {
        "onContactDetected" : "door closed"
    },
    "manufacturer": "Siemens",
    "model":        "MK 240"
  }

But it responses the same when I update the values on the iphone and get them sent to HAP:
(from log on screen)

< hap Ytterdörr get ContactSensorState
> hap Ytterdörr 1

Error while running

Hello, I get the following error when I try to run homekit2mqtt. I cant make a lot of sense of it. Please help.

2017-05-22 13:13:23.383 homekit2mqtt 0.6.5 starting
2017-05-22 13:13:23.946 mqtt trying to connect mqtt://127.0.0.1
2017-05-22 13:13:23.999 using hap-nodejs version 0.4.17
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister
2017-05-22 13:13:24.505 loading HomeKit to MQTT mapping file /usr/local/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2017-05-22 13:13:24.511 loading accessories/WindowCovering.js
/usr/local/lib/node_modules/homekit2mqtt/accessories/WindowCovering.js:3
var {mqttPub, mqttSub, mqttStatus, log, newAccessory, Service, Characteristic} = iface;
^

SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at loadAccessory (/usr/local/lib/node_modules/homekit2mqtt/index.js:168:28)
at /usr/local/lib/node_modules/homekit2mqtt/index.js:179:9
at Array.forEach (native)

Curtains randomly open.

I use your awesome script to control my self built electric curtains. It works perfect, but sometimes my curtains randomly open. I checked the debug info, and it doesn't say anything strange: it really looks like it really receives an open command from homekit:

 hap set Curtain 1 TargetPosition 100

The interesting thing is that when the last scene I used is a scene that opens 2 curtains. Only those two curtains open. If I recently controlled all 4 curtains. All 4 curtains open. It look like's Homekit toggles the most recent command.

Any idea where to look for any clues or solutions?

Does HAP-NodeJS needed to already be installed?

Does HAP-NodeJS needed to already be installed for this to work or does this install hap-nodejs as well?

I already have HAP-NodeJs on my raspberry pi - what would be the process to install this?

MQTT offline/reconnect

Hi, when I tried to run homekit2mqtt mqtt goes offline and tries to reconnect for ever.
How can I fix it?

pi@raspberrypi:~ $ homekit2mqtt -v debug
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister
2017-10-22 21:23:33.134 homekit2mqtt 0.7.2 starting
2017-10-22 21:23:33.155 mqtt trying to connect mqtt://127.0.0.1
2017-10-22 21:23:33.747 using hap-nodejs version 0.4.33
2017-10-22 21:23:33.799 loading HomeKit to MQTT mapping file /usr/local/lib/node_modules/homekit2mqtt/example-homekit2mqtt.json
2017-10-22 21:23:33.805 loading accessories/Switch.js
2017-10-22 21:23:33.814 addBridgedAccessory Switch Switch
2017-10-22 21:23:33.832 mqtt subscribe stat/sonoff/POWER
2017-10-22 21:23:33.845 hap created 1 Accessories
2017-10-22 21:23:33.847 hap publishing bridge "MQTT Bridge" username=CC:22:3D:E3:CE:F6 port=51826 pincode=031-45-154
2017-10-22 21:23:33.954 mqtt subscribe #
2017-10-22 21:23:34.050 hap Bridge listening on port 51826
2017-10-22 21:23:34.053 http server listening on port 51888
2017-10-22 21:23:34.067 mqtt offline
2017-10-22 21:23:35.070 mqtt reconnect
2017-10-22 21:23:36.100 mqtt reconnect
2017-10-22 21:23:37.110 mqtt reconnect
2017-10-22 21:23:38.117 mqtt reconnect

Thermostat clarification

First, thanks for a great project, I was up and running in no time with a bunch of custom built accessories.

On Thermostats, is there any way to have the characteristic Ito only 0 and 1 (off and heat, no cool or auto) ?
Also as you move the slider to change the setpoint, a lot of messages get posted, is there a way to only post the last message? Going over the code, it looks like there may be some similar functionality in the WindowCovering.js

The reason I ask, is I'm using this for a spa heater. Obviously no cool or auto mode, and changing the temperature set point is very slow since I need to re-program the thermostat over a RS485 interface. So rather than buffer all the temperature set point changes and wait for a period of time with no activity to action the last one, it would obviously be easier to only send setpoint once the user has clicked off the icon, but not sure if that's an event you can catch or not.

Thanks again for this project.

Not possible to set targettemperature above 35 degrees

I'm not sure if this is in HAP-NodeJS or the app used for changing the value (EVE home) or some other change.
The water temperature has a setpoint of 60 at home, but I guess the temperature settings are meant only for Air temperature.
The value is not updated on screen if it is above 35, and the value can temporary bet set to a slightly higher value

cannot start homekit2mqtt

This is my homekit2mqrr.json

"Lightbulb1":{
    "service":  "Lightbulb",
    "name":     "Luce studio",
    "topic": {
      "setOn":          "/Bridge01/mcpgpio/9",
      "statusOn":       "/Bridge01/state/stud"
             },

     "payload":{
      "onTrue":0,
      "onFalse":1
             }

 }

2016-12-09 01:11:42.399 <info>  homekit2mqtt 0.6.5 starting
2016-12-09 01:11:43.002 <info>  mqtt trying to connect mqtt://127.0.0.1
2016-12-09 01:11:43.058 <info>  using hap-nodejs version 0.4.17
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
2016-12-09 01:11:43.356 <info>  using directory /usr/local/lib/node_modules/homekit2mqtt/node_modules/ for persistent storage
2016-12-09 01:11:43.381 <info>  loading HomeKit to MQTT mapping file /usr/local/lib/node_modules/homekit2mqtt/homekit2mqtt.json
module.js:433
    throw err;
    ^

SyntaxError: /usr/local/lib/node_modules/homekit2mqtt/homekit2mqtt.json: Unexpected token :
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:430:27)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> 

(/home/udamianu/.nvm/versions/node/v5.7.0/lib/node_modules/homekit2mqtt/index.js:173:15)

    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)

only an object to try. from the example..

can you help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.