Giter Site home page Giter Site logo

Comments (13)

hobbyquaker avatar hobbyquaker commented on August 23, 2024

The payload format can be either an object with val attribute or just a plain value, works both - so this should not be the problem.
The Message published on the topic you configured for statusOn should be retained, is that the case? Can you please provide the config snippet of the outlet accessory as well as the debug log showing switch on/off?

from homekit2mqtt.

rcarmo avatar rcarmo commented on August 23, 2024

The Message published on the topic you configured for statusOn should be retained, is that the case?

No, not quite. I've been reading through the code, and I now realise that homekit2mqtt works quite differently from the homebridge plugin (which in turn sends out messages in tele/devicename/STATE to force the the accessories report their state when it starts). Also, my Sonoff outlets send out notifications when they're manually powered on, so the topic semantics are different.

I'm going to capture a couple of log sequences and get back to you on this.

from homekit2mqtt.

rcarmo avatar rcarmo commented on August 23, 2024

OK, so here's a log of what homebridge sends out to the outlets:

# initial telemetry setting
cmnd/socket3/TelePeriod:'60'
# outlet reply
stat/socket3/RESULT:'{"TelePeriod":"60"}'

# switch off command
cmnd/socket3/POWER:'OFF'
# outlet reply
stat/socket3/RESULT:'{"POWER":"OFF"}'
# outlet status report (happens after the reply)
stat/socket3/POWER:'OFF'

# switch on command
cmnd/socket3/POWER:'ON'
# outlet reply
stat/socket3/RESULT:'{"POWER":"ON"}'
# outlet status report (happens after the reply)
stat/socket3/POWER:'ON'

# manual off
stat/socket3/RESULT:'{"POWER":"OFF"}'
stat/socket3/POWER:'OFF'

# recurring telemetry
tele/socket3/STATE:b'{"Time":"2017-12-25T23:56:50","Uptime":120,"Vcc":3.122,"POWER":"OFF","Wifi":{"AP":1,"SSId":"IoT","RSSI":48,"APMac":"DC:A4:CA:XX:XX:XX"}}'

Based on the above, I'm tempted to assume that this is the config I need:

  "topic": {
    "statusOn": "stat/socket3/POWER",
    "setOn": "cmnd/socket3/POWER"
  },
  "payload": {
    "onTrue": "ON",
    "onFalse": "OFF"
  },

...but on a first attempt nothing happens when I switch the outlet on manually, and reading through the code I don't see any obvious status checks... Any ideas?

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on August 23, 2024

are the messages on `stat/socket3/POWER´ published retained?

from homekit2mqtt.

rcarmo avatar rcarmo commented on August 23, 2024

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on August 23, 2024

I guess then that's the issue. Homekit2mqtt relies on getting retained status messages. To be sure you could just test if it behaves ok when you publish the status again after start of homekit2mqtt.

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on August 23, 2024

Question is now: do have the possibility to retain these messages? Otherwise - implementing a get-topic config var to all characteristics wouldn't be that much effort, could do it, but can't promise when.

from homekit2mqtt.

rcarmo avatar rcarmo commented on August 23, 2024

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on August 23, 2024

hmm I don‘t think thats odd, thats what retained messages are made for - giving clients the possibility to get the last known status without having to send a message to request a status update. I think it‘s odd not to retain these messages :-)
Think of a User Interface e.g that shows hundred or more devices - do you really think it‘s better to send out 100 status request messages or just to subscribe and receive them retained?

from homekit2mqtt.

mattsheffiel avatar mattsheffiel commented on August 23, 2024

If I'm understanding correctly you are using Sonoff devices running the Sonoff-Tasmota firmware. Is that right?

If so it seems that they can be configured to set retain on messages. It is mentioned in the commands section of the wiki for the repo. Search the page for "PowerRetain." I don't have any of these devices yet so I can't test it on my end but that may fix your problem.

from homekit2mqtt.

hobbyquaker avatar hobbyquaker commented on August 23, 2024

Will close the issue for now, feel free to reopen if you want to discuss this further.

from homekit2mqtt.

alimovichpro avatar alimovichpro commented on August 23, 2024

Hello ! I have the same problem. After starting homekit2mqtt all switches is ON and no sensor information.

from homekit2mqtt.

mattsheffiel avatar mattsheffiel commented on August 23, 2024

You need to make sure that your devices are setting the retain flag when they send their messages to your MQTT broker. If you devices aren't setting this flag the MQTT broker just passes the message along and then forgets it. HomeKit2MQTT itself does not store the state of MQTT devices and relies on the MQTT broker to give it the last known state when it starts up. Hope that helps.

from homekit2mqtt.

Related Issues (20)

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.