GithubHelp home page GithubHelp logo

Comments (32)

brefra avatar brefra commented on August 16, 2024 1

Yes they are hard coded. Tasmota is focused more on light switches, but it is easy to use and also supports various sensors.
But the values can be changed already on your plugin, so this should not be a problem or.

Tasmota does allow custom topics and values. You need to setup rules for this.
I did configure my sonoff sv to publish the doorstate to topic "status/garagedoor" using the configuration below.

General config

  1. switchtopic 0

for the open sensor connected to switch 2 in tasmota

  1. switchmode2 1
  2. rule1 on switch2#state=0 do publish status/garagedoor TOGGLE endon on switch2#state=1 do publish status/garagedoor o endon
  3. rule1 1

for the closed sensor connected to switch 3 in tasmota

  1. switchmode3 1
  2. rule2 on switch3#state=0 do publish status/garagedoor 1 endon on switch3#state=1 do publish status/garagedoor c endon
  3. rule2 1

In homebridge I use this config for the garagedoor

{
"accessory": "mqttthing",
"type": "garageDoorOpener",
"name": "Garage door",
"url": "...",
"caption": "Garage door",
"logMqtt": true,
"topics":
{
"getCurrentDoorState": "status/garagedoor",
"setTargetDoorState": "cmnd/garagedoor/sonoff/power",
"getObstructionDetected": ""
},
"doorValues": ["1", "TOGGLE", "o", "c", "s"],
"onValue": "On",
"offValue": "Off"
}

Note, be aware mqttthing currently doesn't keep your homekit garagedoor in sync if the door has been controlled from outside of homebridge. I've fixed that in pull request #28

from homebridge-mqttthing.

tomtzeng avatar tomtzeng commented on August 16, 2024 1

Due to Homekit need 2 kind of parameter (TargetDoorState & CurrentDoorState) to show door direction of movement. So I refer to @brefra 's rule setting on Tasmota and modify it to meet my condition.
I just modify rule 1 & rule 2 as below.
rule1
on switch3#state=0 do publish stat/garagedoor/doorstatus {"cur":"TOGGLE","tar":""} endon
on switch3#state=1 do publish stat/garagedoor/doorstatus {"cur":"OPENING","tar":"ON"} endon

rule 2
on switch2#state=0 do publish stat/garagedoor/doorstatus {"cur":"ON","tar":""} endon
on switch2#state=1 do publish stat/garagedoor/doorstatus {"cur":"CLOSING","tar":"TOGGLE"} endon

which switch3 is close reed switch and switch2 is my open reed switch, which link to TX& RX of my SONOFF 4CH pro.
ON is meaning OPEN. TOGGLE is meaning CLOSED. I have to set this up or sonoff will not work.
I suppose if door status is opening the target status must be OPEN, and if door is going to closing the target must be CLOSED.
below is homebridge config
{
"accessory": "mqttthing",
"type": "garageDoorOpener",
"name": "garageDoor",
"url": "XXXX",
"username": "username",
"password": "password",
"caption": "Garage door",
"logMqtt": false,
"topics": {
"getCurrentDoorState": {
"topic": "stat/garagedoor/doorstatus",
"apply": "return JSON.parse(message).cur;"
},
"getTargetDoorState": {
"topic": "stat/garagedoor/doorstatus",
"apply": "return JSON.parse(message).tar;"
},
"setTargetDoorState": "cmnd/garadoor/gaopr1/POWER",
"getObstructionDetected": ""
},
"doorValues": [
"ON",
"TOGGLE",
"OPENING",
"CLOSING",
"s"
],
"onValue": "ON",
"offValue": "OFF",

}

after the setting, When I use external RF controller to open or close door. It will show correct status in Home APP. I use app to control door work fine as well.

Thanks for all of your suggestion to let the MQTTTHING is working fine to me.

from homebridge-mqttthing.

tomtzeng avatar tomtzeng commented on August 16, 2024 1

Hi Jamie,
for MQTT Setting:
pic1
for others setting:
PIC2

from homebridge-mqttthing.

arachnetech avatar arachnetech commented on August 16, 2024

Would it be possible to use a single topic from both sensors publishing the four different state values (opening, open, closing, closed), as per my comment in #14 (comment) ?

from homebridge-mqttthing.

Kepete avatar Kepete commented on August 16, 2024

No. The Tasmota just gives the state. If a specific reed switch "ON" or "OFF".
Every reed switch has it's own MQTT topic. Also the relay has it's own topic.
So the logic, if it is opening or closing should be done on the homebridge side.

For example:
Door is closed = reed switch1 is closed, it will publish "OFF". Homebridge now needs to understand that "off" from reed switch1 topic means the garage door closed.
Door start to move open = reed switch1 is open, it will publish "ON". Homebridge now needs to understand that "on" from reed switch1 topic means the garage door is opening.

Door comes to fully open position = reed switch2 is closed, it will publish "OFF". Homebridge now needs to understand that "off" from reed switch2 topic means the garage door is fully open.
Door starts to close = reed switch2 is opened, it will publish "ON". Homebridge now needs to understand that "on" from reed switch2 topic means the garage door is closing.

from homebridge-mqttthing.

arachnetech avatar arachnetech commented on August 16, 2024

Pity Tasmota can't be configured in that way. Are the ON and OFF values hard-coded too? They don't seem very logical here.

from homebridge-mqttthing.

Kepete avatar Kepete commented on August 16, 2024

Yes they are hard coded. Tasmota is focused more on light switches, but it is easy to use and also supports various sensors.
But the values can be changed already on your plugin, so this should not be a problem or.

from homebridge-mqttthing.

arachnetech avatar arachnetech commented on August 16, 2024

Thanks, I see. I'll try to get this option into the next version.

from homebridge-mqttthing.

Kepete avatar Kepete commented on August 16, 2024

Awesome. Waiting for it :)

from homebridge-mqttthing.

hejsiri avatar hejsiri commented on August 16, 2024

How do you progress at work? :-)

from homebridge-mqttthing.

hejsiri avatar hejsiri commented on August 16, 2024

What do you think about this?
iomax/homebridge-mqttgaragedoor#10 (comment)
How create rules on this case?

from homebridge-mqttthing.

vk3jme avatar vk3jme commented on August 16, 2024

Hi @tomtzeng, thanks for providing your current setup for MQTTTHING.
I'm a newb with MQTT and I am using a SONOFF TH to open my garage as my first real Home Automation project. I chose the TH as it has two GPIO's available via the 2.5mm socket without modification and minimal hacking was done to convert the relay suit the garage door opener.

Can you please clarify a few things for me please in your json setup.
Is 'garagedoor' the MQTT Client name of your device?

"setTargetDoorState": "cmnd/garadoor/gaopr1/POWER"

This line is throwing an error for me, is garadoor a type for garagedoor and is gaopr1 meant to be the topic assigned to your device?

Again I'm pretty new to MQTT and still learning, so thanks for your info so far, it's the most valuable clue I have found so far how to Homebridging my garage door.

Thank you,

Jamie

from homebridge-mqttthing.

tomtzeng avatar tomtzeng commented on August 16, 2024

from homebridge-mqttthing.

vk3jme avatar vk3jme commented on August 16, 2024

Hi @tomtzeng,
No image received in your response.

from homebridge-mqttthing.

vk3jme avatar vk3jme commented on August 16, 2024

Thank you @tomtzeng, I have managed to get it to work with your configuration.
One thing to note is that pulsetime1, 10 was required to emulated the relay pressing the button on my opener. If left default the above configuration will only toggle the relay.

Much appreciated - Thank you!

from homebridge-mqttthing.

hoenes avatar hoenes commented on August 16, 2024

Thanks to the info in this thread, I could setup my selfmade „smart“ (1980s BOSCH Torlift, Tasmota sonoff TH10 + extra relay and the allready in place reed contacts) garagedooropener with homekit.
Every thing is working as expectet with one exception: When starting/restarting the homebridge service, the garagedoor appears in open state in homebridge. Only cycling the door once gets it in sync. I understand that the homebride doesn‘t know anything from the garagedoor unless the switchstate of switch2 or 3 (the reed contacts) changes, but is their a possibility to bring homebridge up with the garagedoor closed as the initial state? As my garage is almost all the time closed, so this would make more sense in my usecase.
thanks for your ideas

from homebridge-mqttthing.

arachnetech avatar arachnetech commented on August 16, 2024

@hoenes This should be possible using the startPub setting, described briefly in https://github.com/arachnetech/homebridge-mqttthing#publishing-values-on-start-up.

There's an example in "Test lightbulb" in the test config file:

      "startPub": {
        "test/lightbulb/setOn": "1",
        "test/lightbulb/getOn": "1",
        "test/lightbulb/setBrightness": "200",
        "test/lightbulb/getBrightness": "200",
        "test/lightbulb": "Hello world"
      }

from homebridge-mqttthing.

hoenes avatar hoenes commented on August 16, 2024

@arachnetech thanks a lot

"startPub": { "stat/garagedoor/doorstatus": "{\"cur\":\"TOGGLE\"}" }

did the trick.

EDIT:

almost

as homebridge was fine with the above, Apples Home App showed the garagedoor in OPENING state.
I had to add the CLOSING command executing before the CLOSED command.
Not sure if homebridge it self or just the UI plugin causes that I can‘t add two publish commands of the same topic successively. So I had to do the second, the CLOSED, command in an extra startPub at one of my other mqttthing accessories.

"startPub": { "stat/garagedoor/doorstatus": "{\"cur\":\"CLOSING\",\"tar\":\"TOGGLE\"}" } ... "startPub": { "stat/garagedoor/doorstatus": "{\"cur\":\"TOGGLE\",\"tar\":\"\"}" }

from homebridge-mqttthing.

iondarie avatar iondarie commented on August 16, 2024

@hoenes After some testing i found out that you only need one startPub that specifies both current and target states, this way homebridge and home are in sync.

Here is my config with only one startPub:

{
            "accessory": "mqttthing",
            "type": "garageDoorOpener",
            "name": "Garage",
            "url": "mqtt://localhost",
            "caption": "Garage door",
            "logMqtt": false,
            "topics": {
                "getCurrentDoorState": {
                    "topic": "a_porti/stat/garage",
                    "apply": "return JSON.parse(message).cur;"
                },
                "getTargetDoorState": {
                    "topic": "a_porti/stat/garage",
                    "apply": "return JSON.parse(message).tar;"
                },
                "setTargetDoorState": "a_porti/cmnd/POWER1",
                "getObstructionDetected": ""
            },
            "doorValues": [
                "ON",
                "TOGGLE",
                "OPENING",
                "CLOSING",
                "s"
            ],
            "onValue": "ON",
            "offValue": "OFF",
            "startPub": {
                "a_porti/stat/garage": "{\"cur\":\"TOGGLE\",\"tar\":\"TOGGLE\"}"
            }
        }

from homebridge-mqttthing.

hoenes avatar hoenes commented on August 16, 2024

Thanks @iondarie that's a cleaner solution approach 👍🏻

from homebridge-mqttthing.

iondarie avatar iondarie commented on August 16, 2024

@hoenes unfortunately even with this solution the plugin does not work properly.

If your garage is closed please try to issue a command to siri to close the garage.

The result of your command will be the garage door opening...

Hopefully #192 will be taken into account someday.

from homebridge-mqttthing.

hoenes avatar hoenes commented on August 16, 2024

@hoenes unfortunately even with this solution the plugin does not work properly.

If your garage is closed please try to issue a command to siri to close the garage.

The result of your command will be the garage door opening...

@iondarie of course. There is only one command to toggle the relay/switch for the garage door (as it was and is without homebridge integration) so if you trigger it and the door is closed, it will open (or closing when it is already open.)
For what you want, there need to be a code (maybe possible with node red) that checks the actual state of the garagedoor and takes it into account.
Sorry, but that won't work with this approach.

from homebridge-mqttthing.

iondarie avatar iondarie commented on August 16, 2024

mqttthing does the necessary checks for the security system, if it is armed and i issue another arm command it ignore’s it.

Unfortunately Ill need to find another solution for my garage it seems

from homebridge-mqttthing.

NorthernMan54 avatar NorthernMan54 commented on August 16, 2024

If your using mqtt, take a look at node-red, homebridge-automation and HomeKit-bridged

You can build your own “accessory”

from homebridge-mqttthing.

rasgeek avatar rasgeek commented on August 16, 2024

Yes they are hard coded. Tasmota is focused more on light switches, but it is easy to use and also supports various sensors.
But the values can be changed already on your plugin, so this should not be a problem or.

Tasmota does allow custom topics and values. You need to setup rules for this.
I did configure my sonoff sv to publish the doorstate to topic "status/garagedoor" using the configuration below.

General config

  1. switchtopic 0

for the open sensor connected to switch 2 in tasmota

  1. switchmode2 1
  2. rule1 on switch2#state=0 do publish status/garagedoor TOGGLE endon on switch2#state=1 do publish status/garagedoor o endon
  3. rule1 1

for the closed sensor connected to switch 3 in tasmota

  1. switchmode3 1
  2. rule2 on switch3#state=0 do publish status/garagedoor 1 endon on switch3#state=1 do publish status/garagedoor c endon
  3. rule2 1

In homebridge I use this config for the garagedoor

{
"accessory": "mqttthing",
"type": "garageDoorOpener",
"name": "Garage door",
"url": "...",
"caption": "Garage door",
"logMqtt": true,
"topics":
{
"getCurrentDoorState": "status/garagedoor",
"setTargetDoorState": "cmnd/garagedoor/sonoff/power",
"getObstructionDetected": ""
},
"doorValues": ["1", "TOGGLE", "o", "c", "s"],
"onValue": "On",
"offValue": "Off"
}

Note, be aware mqttthing currently doesn't keep your homekit garagedoor in sync if the door has been controlled from outside of homebridge. I've fixed that in pull request #28

Hi can i use this config with a sonoff basic flashed with tasmota, configured as pulse relay ?

from homebridge-mqttthing.

rasgeek avatar rasgeek commented on August 16, 2024

I mod my sonoff basic to send a pulse to my garage door opener and that worked but now I would like to get it to show up in home bridge as the garage door. the following config works but its constantly in closing state.
{
"accessory": "mqttthing",
"url": "http://192.168.84.24:1883",
"type": "garageDoorOpener",
"name": "Gate",
"caption": "Main Gate",
"topics": {
"setLockTargetState": "main-gate/cmnd/Power1",
"setTargetDoorState": "main-gate/cmnd/Power1"
},
"doorCurrentValues": [
"Open",
"Closed"
],
"doorTargetValues": [
"ON",
"OFF"
],
"startPub": {
"main-gate/stat/Power1": ""
}

from homebridge-mqttthing.

iondarie avatar iondarie commented on August 16, 2024

I managed to get the proper states of the garage with the following rules on tasmota:

Rule1 on switch1#state=0 do publish2 %topic%/stat/garaj OPEN endon on switch1#state=1 do publish2 %topic%/stat/garaj CLOSING endon on switch1#state=1 do publish2 %topic%/target/garaj CLOSED endon
Rule2 on switch2#state=0 do publish2 %topic%/stat/garaj CLOSED endon on switch2#state=1 do publish2 %topic%/stat/garaj OPENING endon on switch2#state=1 do publish2 %topic%/target/garaj OPEN endon

and the following config on homebridge:

      {
            "accessory": "mqttthing",
            "type": "garageDoorOpener",
            "url": "mqtt://localhost",
            "name": "Garage Test",
            "username": "#####",
            "password": "#####",
            "topics": {
                "getOnline": "porti/tele/LWT",
                "getCurrentDoorState": "porti/stat/garaj",
                "getTargetDoorState": "porti/target/garaj",
                "setTargetDoorState": "porti/cmnd/POWER1"
            },
            "onlineValue": "Online",
            "offlineValue": "Offline",
            "doorCurrentValues": [
                "OPEN",
                "CLOSED",
                "OPENING",
                "CLOSING"
            ],
            "doorTargetValues": [
                "OPEN",
                "CLOSED"
            ]
        }

There is no need for startPub as now i am using publish2 in my tasmota rules witch sends the messages with the retain flag and that results in mqttthing getting the correct state of my garage door even after i reboot my homebridge server or i am controlling the garage with the RF remote.

The last remaining problem that i have to solve is sending the correct payload for the ON & OFF at the "setTargetDoorState": "porti/cmnd/POWER1" as my motor uses impulses to work.

@arachnetech please if you have some time can we find a solution for us pulse power 1 button users :D

from homebridge-mqttthing.

rasgeek avatar rasgeek commented on August 16, 2024

Due to Homekit need 2 kind of parameter (TargetDoorState & CurrentDoorState) to show door direction of movement. So I refer to @brefra 's rule setting on Tasmota and modify it to meet my condition.
I just modify rule 1 & rule 2 as below.
rule1
on switch3#state=0 do publish stat/garagedoor/doorstatus {"cur":"TOGGLE","tar":""} endon
on switch3#state=1 do publish stat/garagedoor/doorstatus {"cur":"OPENING","tar":"ON"} endon

rule 2
on switch2#state=0 do publish stat/garagedoor/doorstatus {"cur":"ON","tar":""} endon
on switch2#state=1 do publish stat/garagedoor/doorstatus {"cur":"CLOSING","tar":"TOGGLE"} endon

which switch3 is close reed switch and switch2 is my open reed switch, which link to TX& RX of my SONOFF 4CH pro.
ON is meaning OPEN. TOGGLE is meaning CLOSED. I have to set this up or sonoff will not work.
I suppose if door status is opening the target status must be OPEN, and if door is going to closing the target must be CLOSED.
below is homebridge config
{
"accessory": "mqttthing",
"type": "garageDoorOpener",
"name": "garageDoor",
"url": "XXXX",
"username": "username",
"password": "password",
"caption": "Garage door",
"logMqtt": false,
"topics": {
"getCurrentDoorState": {
"topic": "stat/garagedoor/doorstatus",
"apply": "return JSON.parse(message).cur;"
},
"getTargetDoorState": {
"topic": "stat/garagedoor/doorstatus",
"apply": "return JSON.parse(message).tar;"
},
"setTargetDoorState": "cmnd/garadoor/gaopr1/POWER",
"getObstructionDetected": ""
},
"doorValues": [
"ON",
"TOGGLE",
"OPENING",
"CLOSING",
"s"
],
"onValue": "ON",
"offValue": "OFF",

}

after the setting, When I use external RF controller to open or close door. It will show correct status in Home APP. I use app to control door work fine as well.

Thanks for all of your suggestion to let the MQTTTHING is working fine to me.

how many sensors do you have connected ? can I do it with one on gpio 3 ?

from homebridge-mqttthing.

arachnetech avatar arachnetech commented on August 16, 2024

I've just added an alternative way to expose garage door opening/closing state. Instead of publishing to the getCurrentDoorState topic, you can now publish to getDoorMoving - publishing true if the door is moving or false if it has reached its final state (with the usual options for Boolean values). Mqttthing will work out the corresponding opening/closing/open/closed state in relation to the target state. This might make what you're doing easier.

If you have a reed switch detecting when the door is fully-closed, and another detecting when the door is fully-opened, you could set them both to publish true to the getDoorMoving topic when the door starts to move away from them, and false when the door comes to rest at the other position.

As an even simpler option it's possible to configure a getDoorMoving topic but never publish it. Homekit will then just toggle the garage door between open and closed.

from homebridge-mqttthing.

ceraz68 avatar ceraz68 commented on August 16, 2024

The last remaining problem that i have to solve is sending the correct payload for the ON & OFF at the "setTargetDoorState": "porti/cmnd/POWER1" as my motor uses impulses to work.

Just use an apply statement in the topic "apply": "return 'ON'". That will change the HomeKit O or C instruction to "ON" for the power command in tasmota

from homebridge-mqttthing.

ceraz68 avatar ceraz68 commented on August 16, 2024

I was struggling with my garage door opener as there were no working examples in the Wiki and all the know-how was spread over multiple threads like this one (thanks for sharing!). I have a sonoff with tasmota so it made more sense to combine tasmota rules with Mqttthing (my go-to Mqtt accessory ;-)).

An annoying issue to resolve was Siri/HK close instruction for an already closed door would actually open it. In the past I captured this with Siri Shortcuts but this is now covered by Mqttthing.

I posted examples on the wiki of a working config with two topics and another with a single topic. Hope they will work for others.

from homebridge-mqttthing.

Jepes-sudo avatar Jepes-sudo commented on August 16, 2024

Hello, I am new here and I have a very basic query with which I am sure you can help me.

I've been looking for the solution around here, reading for days and I can't find it (it must be very basic for my level).

I have a Sonoff 4 CH Rev.2 with tasmota and I don't understand how to make it work with my homebridge setup, I have read about accessory groups, but I think this does not working for me.

Can you refer me to the "rules" on how to declare the Sonoff itself and their individual four buttons to make them work for me?

Thank you in advance!

My code:

`{
"accessory": "mqttthing",
"type": "custom",
"name": "Sonoff4CH",
"url": "192.168.254.129",
"services": [
{
"type": "outlet",
"name": "Sonoff4CH1",
"topics": {
"getOn": "home/get/Sonoff4CH/Sonoff4CH1/POWER",
"setOn": "home/set/Sonoff4CH/Sonoff4CH1/POWER"
},
"onValue": "ON",
"offValue": "OFF",
"startPub": {
"cmnd/Sonoff4CH/Sonoff4CH1/POWER": ""
}
},
{
"type": "lightbulb",
"name": "Sonoff4CH2",
"topics": {
"getOn": "home/get/Sonoff4CH/Sonoff4CH2/POWER",
"setOn": "home/set/Sonoff4CH/Sonoff4CH2/POWER"
},
"onValue": "ON",
"offValue": "OFF",
"startPub": {
"cmnd/Sonoff4CH/Sonoff4CH2/POWER": ""
}
},
{
"type": "lightbulb",
"name": "Sonoff4CH3",
"topics": {
"getOn": "home/get/Sonoff4CH/Sonoff4CH3/POWER",
"setOn": "home/set/Sonoff4CH/Sonoff4CH3/POWER"
},
"onValue": "ON",
"offValue": "OFF",
"startPub": {
"cmnd/Sonoff4CH/Sonoff4CH3/POWER": ""

        }
        }
    ]
}`

Foto 28-11-20 11 35 18
Foto 28-11-20 11 36 55

from homebridge-mqttthing.

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.