Closed bohtho closed 4 years ago
Can anyone reproduce ? This is the case in iOS 13.1 at least.
I don't use this service , but could you post your topic and payload JSON definitions.
I keep HomeKit in sync with, and control, a Danalock zigbee door lock.
Just {"name":"Døren","service_name":"Lås","service":"LockMechanism"}
to topic homebridge/to/add
.
I removed and created it via nodered-contrib-node-homekit-bridged instead to test, and then it keeps its state.
Hello people,
I have the same problem, I think this must be a security issue, because when I restart it goes back to Unsecured, so I made some variables to detect reboot and not have this problem for now, below is my configured accessory, thank you in advance .
{
"accessory": "mqttthing",
"type": "lockMechanism",
"name": "Portao Pequeno",
"url": "http://localhost:1883",
"username": "admin",
"password": "******",
"topics": {
"setLockTargetState": "hb/set/fechaduras/portaopequeno/target",
"getLockTargetState": "hb/get/fechaduras/portaopequeno/target",
"getLockCurrentState": "hb/get/fechaduras/portaopequeno/current"
},
"lockValues": [
"Unsecured",
"Secured",
"Jammed",
"Unknown"
]
}
Above, log do BOOT
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
WiFi e MQTT down: iniciando WiFi
WiFi: Conectando em Clone ...
WiFi iniciando, MQTT down, esperando 0 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..
WiFi up, MQTT down. IP = 192.168.1.202
WEB: Updater ready, open http://esp01.local in your browser and login with username 'admin' and password '*******'.
WiFi up, MQTT starting
MQTT: Connecting to broker @192.168.1.200 ... ok.
MQTT << [hb/esp01/LWT] 1
Publicando no LWT
MQTT << [hb/set/fechaduras/portaopequeno/target] Secured
Publicando no SETLOCKTARGETSTATE
MQTT << [hb/get/fechaduras/portaopequeno/current] Secured
GET no GET_LOCK_CURRENT_STATE Secured
MQTT: Subscribed to [hb/set/fechaduras/portaopequeno/target]
WiFi up, MQTT up on first try.
MQTT >> [hb/set/fechaduras/portaopequeno/target] Unsecured
Unsecured
I tried to make a publication before PAYLOAD to check if this UNSECURED or SECURED, and even then it didn't work ...
#include <Bounce2.h>
#include "EspMQTTClient.h"
int RELE = 26;
int REINICIO = 0;
#define SWITCH 23
boolean modoPulsador = false; /* true = Pulsador e false interruptor */
#define WIFI_FIX
// Topicos Disponivels
// "setLockTargetState": "hb/set/fechaduras/portaopequeno/target",
// "getLockTargetState": "hb/get/fechaduras/portaopequeno/target",
// "getLockCurrentState": "hb/get/fechaduras/portaopequeno/current"
/* topics */
#define SET_LOCK_TARGET_STATE "hb/set/fechaduras/portaopequeno/target"
#define GET_LOCK_TARGET_STATE "hb/get/fechaduras/portaopequeno/target"
#define GET_LOCK_CURRENT_STATE "hb/get/fechaduras/portaopequeno/current"
#define LIGA LOW
#define DESLIGA HIGH
// Instantiate a Bounce object :
Bounce debouncer01 = Bounce();
EspMQTTClient client(
"Clone",
"*******",
"192.168.1.200", // MQTT ip do servidor
"admin", // Pode ser omitido se quiser
"******", // Pode ser omitido se quiser
"esp01", // Nome do cliente tem que ser UNICO
1883 // MQTT porta, a porta padrão é 1883.
);
void setup()
{
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(RELE, OUTPUT);
pinMode(SWITCH, INPUT_PULLUP);
debouncer01.attach(SWITCH); // Use the bounce2 library to debounce the built in button
debouncer01.interval(50); // Input must be low for 50 ms
// Optionnal functionnalities of EspMQTTClient :
client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
client.enableLastWillMessage("hb/esp01/LWT", "0", true /* retain */); // You can activate the retain flag by setting the third parameter to true
}
// This function is called once everything is connected (Wifi and MQTT)
// WARNING : YOU MUST IMPLEMENT IT IF YOU USE EspMQTTClient
void onConnectionEstablished()
{
// Publish a message to "hb/esp01/online"
client.publish("hb/esp01/LWT", "1", true /* retain */); // You can activate the retain flag by setting the third parameter to true
Serial.println("Publicando no LWT");
client.publish(SET_LOCK_TARGET_STATE, "Secured");
Serial.println("Publicando no SETLOCKTARGETSTATE");
if(digitalRead(SWITCH)){
client.publish(GET_LOCK_CURRENT_STATE, "Unsecured");
Serial.println("GET no GET_LOCK_CURRENT_STATE Unsecured");
}else{
client.publish(GET_LOCK_CURRENT_STATE, "Secured");
Serial.println("GET no GET_LOCK_CURRENT_STATE Secured");
}
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe(SET_LOCK_TARGET_STATE, [](const String & payload ) {
Serial.println(payload);
if(REINICIO == 1){
if (payload.equals("Unsecured") && !digitalRead(SWITCH)) {
digitalWrite(RELE, HIGH);
delay(250);
digitalWrite(RELE, LOW);
}
}else{
REINICIO = 0;
}
});
}
Thanks...
A Door Lock Mechanism created via Homebridge-MQTT always reverts to unlocked status in HomeKit when reopening Home.app resulting in "Locking ..." because of the LockTargetState (if real last state is locked).
If I create the Door Lock in HomeKit via eg. node-red-contrib-homekit-bridged the state is remembered between activating home.app.