SOnOff Touch - possible to send a MQTT message only after a double tap?

248 views
Skip to first unread message

Kevin K

unread,
Sep 28, 2017, 1:24:36 AM9/28/17
to SonoffUsers
I've just flashed V5.8.0 via Platform IO, and all is well, however I would like to get a MQTT message when the button is pressed on my sonoff touch as well as a status when the relay is set. I get a status change message on 
    
     stat/sonoff/POWER

but this doesn't tell me where the signal  has come from.

Is there a way of getting the local touch button to show up as a MQTT message?
Also is it possible to get a different message from double tapping the Button?

I use OpenHAB and I would like the different signals so I can either leave the switch permanently ON or activate a timer that will turn the switch off after say 5 minutes via a timer.

A triple tap makes the switch go into WIFI setup mode, and a press and hold resets the module, so it must be capable of detecting multiple taps, but I'm not sure where to tweak them to do what I need.

Kevin K

unread,
Sep 28, 2017, 6:11:11 PM9/28/17
to SonoffUsers
To answer my own question, I've just changed to ESPEasy R120_4 which has allowed me to do all I need. If anyone else does this beware that ESPEasy R147 and V2.0.0-dev12 stop the switch from booting. R120_4 will load from Tasmota's web page which makes life easy.

wbsi...@gmail.com

unread,
Oct 2, 2017, 9:27:35 PM10/2/17
to SonoffUsers
Just a quick question about your OpenHab experience.. Do you have a problem with your OH install not starting after it has been shutdown or the PC has been restarted. I am having a little bit of a ^*&^*%^&* time with the object/things/items set up and subsequent files.. would youi have an example from each folder.. I'm thinking I might be able to make a batch routine to build the files versus going through the individual folders and editing cfg files..

Kevin K

unread,
Oct 2, 2017, 10:39:30 PM10/2/17
to SonoffUsers
Mine is totally stable on reboot thankfully, BUT I had horrendous problems getting it stable. I'm running a Pi2 and a Pi3 on Linux with a Openhab V2.1 Instance on each. I have hundreds of items, and a lot of rules so a reboot takes around 10 minutes.
Your problem is likely caused by rules being fired before the items they are working on have been initialised, in my case I also was trying to reset the states of items driven by the RFXCOM binding that hadn't been initialised yet. As the OpenHAB is multi threaded it isn't guaranteed that the order that everything comes up is the same after every reboot, so just using a timed delay in my rules was unreliable.and the change from V2.0 to V2.1 ruined my previously stable systems. 
In my case I created a dummy switch item, added it to persistence, and then set it to ON. I then created a startup batch / script file that on reboot of the PC before OpenHAB starts moves most of the rules files into another folder. Then when Openhab starts I have a rule similar to

    rule "copy files back once things are stable
    when Item MyStartupItem changed then
    if (MyStartupItem.state = ON) {
    copy all the rules back into place }
    end

This checks that the system is up before copying the rules back. I also have put all my timed and timer rules into their own file which gets copied once the rest of the rules are loaded, this allows me to work on rules without leaving orphaned timers all over the place which will throw up obscure errors later in the day

Hopefully this makes sense?

Cheers

Kevin

Will Sims Jr

unread,
Oct 3, 2017, 8:11:28 PM10/3/17
to sonof...@googlegroups.com
It is a sorted affair lol.. Actually I haven't put any rules into the mix at all. What I get when I do stop/start it,
and or reboot is a message that "<process name> process is already running under thread pid <number>" usually just a
"main", funny thing is, when I check the PID number in tasks.. there isn't one....
Today was my last day trying to sort out the structure of the "things", "items" and the whole binding.. Maybe I'll
revisit it when the process of adding mqtt driven devices doesn't require a degree in engineering to figure out.. I am
but a lowly web and scripting guy :-D. I was hoping to add it to the services I offer clients... frankly the time and
effort required isn't something one could ethically bill for at a reasonable price....
And I did another fresh install, and a restart.. ironically, when I do install I only go so far as installing the
bindings.. I figured I'd go further when I got it to be stable.
I was going to take some samples of others cfg files to get a feel for the setup, and build scripts to allow a little
simpler method of adding all the mqtt devices.. I really can't understand why it's so hard to add MQTT devices.. they
broadcast very simple messages, so why not just make the binding sniff the topic messages coming from the server and allow
the user to set up the commands as the topic is found.. problem solved!
But honestly this OpenHab doesn't seem very mature, at least for a consumer market. I think at this time I'll just use
firmware that will allow me to build a web interface.. I thought OpenHab would require less time to set up, I could have
built a website faster with more stable results. In my younger years I didn't mind spending days rooting around, but
nowadays if the tech requires too much hands on, it's ditched. The possibility that an update will mess things up or that in
a week it will go wonky is unappealing lol.

Thank for your input and suggestion!
--


Will Sims Jr

SIP/VoIP: will...@pbxes.org

Web Site: wbsimsjr.ddns.net

Music Tracks updated daily
http://willsimsjr.ddns.net/daily.php


Kevin K

unread,
Oct 4, 2017, 12:08:31 AM10/4/17
to SonoffUsers
Is this under Windows or Linux?
The problem with the MQTT part is its an older V1 legacy binding which means each device has to be configured in Items, which is a pain especially as I usually need to reboot mine before its happy. The later V2 bindings which are slowly coming out have a degree of plug and play about them. The change to V2 was I think to make it more consumer friendly, but it has a lot of legacy stuff left which means its a mix of things. With V2 bindings new discoveries are presented in the inbox, so its heading that way.
Whilst mine works very well for me I'd not deploy it to a customer as the ongoing support could be an issue. Once its installed if its left alone and has a scheduled reboot its stable, but I've spent days working on some things, and for me the move from V2.0 to V2.1 made it very unstable until I worked out what was going wrong.

Will Sims Jr

unread,
Oct 4, 2017, 9:26:59 PM10/4/17
to sonof...@googlegroups.com
I'm on a Windows pc.. XP to boot lol.. I've started a switch to Ubuntu and have it on one laptop, I can't seem to bring
myself to changing 'my ole gurl'.
I had looked at a Pi a few weeks ago, after swapping the xbox's media capacities for android boxes.. The Pi is going to
be integrated into the new scheme. I'm thinking it might be able to fill several roles and allow me to put the old dell
server to rest.. I might be able to get a PI this week, I might give OpenHab a day or 2 and try it out again, if I can find real world examples of
the various files used..
Having already implemented ApacheMQTT along with some MQTT tools on the droids/PC I can test what works with the
few test devices I have up... My first IoT Mr Coffee Maker, and an outside weather device.
I tried out a few PHP methods...
I found https://www.cloudmqtt.com/docs-php.html . it is based on https://github.com/bluerhinos/phpMQTT
Initially it didn't work, I had to change the "require" statement in the php code to an "include" statement.. and that
was it.. A successful "ON" message was sent to, and turned on the Coffee Maker! Wahoooo..
a video of it is [https://www.facebook.com/will.sims.5/videos/10213052521923680/]
At least, I can go ahead and start reflashing the devices, while I polish up the interface and do some exploring..


On Tue, 3 Oct 2017 21:08:30 -0700 (PDT)
> > SIP/VoIP: will...@pbxes.org <javascript:>

Kevin K

unread,
Oct 4, 2017, 11:15:50 PM10/4/17
to SonoffUsers
Before taking the plunge with the Pi take a look at alternatives to see if something else makes more sense. The Pi's weakness is its SD Card - mine has just died after around 2 years despite being 32GB with 3/4 of the space unallocated to allow wear leveling, and the logfiles in RAM,  I think the Pi3 supports booting from USB disks which will get around that problem, and I take regular Images of the card which makes rolling back easy if needed.
Once you have Openhab working on Linux I can talk you through getting your SONOFFs to work, and the OpenHAB forum is very helpful too. There is a ready built distro for OpenHAB on a Pi called OpenHabian which may be a lot easier than reinventing the wheel.
For my IoT / 8266 / SOnOfftype devices I use a combination of Tasmota and ESPEasy, and then talk to OH with MQTT, it all works very well. To access OH over the net you have to either use a VPN, MyOpenHAB which is a proxy for the items maintained by the OpenHAB guys, or NGINX as an authentication proxy. Chances are OpenHabian already has NGINX set up, although I don't think its a read only image which I'd recommend converting to on a Pi, as that means it will prolong the life of the SD Card and return from a powercut happily.
Chances are your problems running OH is down to Java Version that will run on XP

Will Sims Jr

unread,
Oct 10, 2017, 3:20:29 PM10/10/17
to sonof...@googlegroups.com
The help would be greatly appreciated, I tried OpenHab on the Ubuntu 16.04LTS and it too did not reboot, but I've used
windoz my whole life. It downloaded and I followed along with some of the material.. I was left questioning my sanity..
I usually check forums out before seeking out help on the very rare occasion. I do not post anymore though. I use
stackoverflow' but, it gets bothersome getting clubbed by people that forget that others are at different stages of ability
or can not completely invest themselves 2000% in each and every venue of technology. Being a decent manager, I am completely
comfortable seeking out others that have the skills I do not.
I'm going to spend a day or 2 flashing the sonoffs and updating the coffee maker.. I promised I'd have the button
working by the middle of the week..
I will more than likely order the Pi weds. I figured the Pi would due for the role I have planned for it... it will
replace the laptop in file, web, and media server roles.
On Wed, 4 Oct 2017 20:15:50 -0700 (PDT)

Kevin K

unread,
Oct 10, 2017, 3:35:01 PM10/10/17
to SonoffUsers
All good, you'll end up using the Pi's version of Linux - Raspbian, "Jessie" has just been replaced by "Stretch," this seems to be the Raspberry equivalent of moving to a later version of Windows. Given that its pretty new I'd stick to Jessie until the inevitable bugs have been ironed out. Also remember that the Pi isn't a high bandwidth with only a 10/100 network port, and a single USB port with onboard USB hub so its never going to set any speed records for file sharing. I'd recommend checking out OpenHabian which has everything ready to write to a flash card, I'd also recommend a USB3 card reader for easy backups together with a larger Micro SD card so there is plenty of space for wear levelling. I've just switched to Samsung Pro Plus 32GB MicroSDHC UHS-I cards, the Pi won't run these cards at their fastest speed, but it does make backing up and restoring card images a lot faster.
Take a look at https://community.openhab.org/t/openhabian-hassle-free-openhab-setup/13379 to read about the ready made card image.
Reply all
Reply to author
Forward
0 new messages