Smart button like Amazon Dash Button

Hi Community,

I hope you can help me with my problem :slight_smile:
First of all, to the situation I need to find a solution for:

I need some kind of button/switch to switch two things in openHAB.

When I first installed openHAB2 and saw, that it is possible to use Dash buttons, I was really happy :slight_smile: Sadly I did not know, that since this year, I am not able to use the dash buttons I have, since the program is discontinued by Amazon.

That is why I am searching for any kind of button to use with openHAB.

Maybe you guys have an idea how to either build a button that would work on a battery or know a product that is cheap and works like the amazon-button or something that can be “hacked” and used for openHAB (over MQTT for example).

Thx in advance :slight_smile:

I remember seeing a Z-Wave button
Fibaro appears to have a product called “The Button”

Hi @JustTotallyMe welcome too the community hopefully you can get some decent answers on your first post :wink:

I use the Philips hue dimmer switch for most of my buttons in OH I also started with amazon dash buttons but have since removed them all from my system as hue outperformed them and since discontinued like you say

31bc38hEFSL.AC_SY400

They are used too change hue lights on/off brighter/dimmer and cycle through scenes

but I don’t connect them too anyting in the hue app and add let openhab process what the button presses mean

The one in my bedroom must do 20 different things based on time pressed, system status, item status ect

The buttons themselfs register different things too short press, long press, and the top button cycles through 4 or 5 different things before reverting back too its original state

They use zigbee and are connected too the hue bridge the hue bridge communicates with OH

I use this:


It’s Z-Wave and $15.

The OP may not be in US, Canada or Mexico, but in a different Z-Wave region.

There are a number of button devices that work with BT, Zigbee or Zwave. Fibaro even calls their’s “The Button”. Just search your shopping site of choice for “Zigbee button” and “Zwave button” (two separate searches) and you should find a number of options. The cheapest one I saw was a Zigbee at $15. Just be sure you get a device that is correct for your region.

DIY is a little challenging here as it requires the ability to create something small and package it up into a nice and tiny enclosure which is hard to do DIY for most of us. But if you went down that route, it should be really simple to do the electronics part using an ESP8266, a pre-made button, and battery pack. There are tons of tutorials and indestructibles for “DIY Dash button”, several with links to 3D printed case model files.

1 Like

Well thanks for all the ideas so far.
@Sharpy I was not aware, that the hue dimmer is so awesome. I do have some of them already for my “normal” hue system but since they are pretty cheap atm I might get a few and use these. So thanks for the idea.
Also regarding zwave and zigbee I will have a look at these options. I also looked at “The Button” but this thing is not really cheap in germany and therefor not my first choice :slight_smile:

Also one thing about zwave and zigbee: Am I correct, that I need a usb-adapter for both of these things? (running OH on windows btw)

1 Like

Zigbee should be compatible with your Hue hub. But otherwise, yes, you would need a USB dongle.

if you need any help with that give me a shout i may be able too help you get it working i think its quite easy now they may just appear in paperUI when i added them i had too use a workaround as they wernt supported i think i had too use the HTTP binding

here is the rule i use for my bedroom switch might give you an idea how i get it too do multiple things (code could probably be alot clearner im not an expert)

rule "Master Bedroom Switch"
when
    Item MbedSwitchWhen changed
then
Thread::sleep(1500)
    if( MbedSwitchWhat.state == "4002"  ) { // Bottom Button
        if( Bed_Trigger.state == ON && Morning_Mode_Ready.state == OFF ) { // going bed
            In_Bed.sendCommand ("ON")
            BULB12USMB_Brightness.sendCommand ("0") 
            Plug1_Switch_MB_Cabinet.sendCommand ("OFF")
            return;
        }
        if( Bed_Trigger.state == ON && Morning_Mode_Ready.state == ON ) { // in bed morning light on
            BULB12USMB_Brightness.sendCommand ("100")
            Plug1_Switch_MB_Cabinet.sendCommand ("ON")
            return; 
        } // add light off
        if( In_Bed.state == ON && BULB12USMB_Brightness.state == 0.00000000 ) { // in bed woke up need light
            BULB12USMB_Brightness.sendCommand ("5")
            return;
        }
        if( In_Bed.state == ON && BULB12USMB_Brightness.state != 0.00000000 ) { // going back asleep lights off
            BULB12USMB_Brightness.sendCommand ("5")
            return;
        }
        if( Bed_Trigger.state == OFF && Morning_Mode_Ready.state == OFF && In_Bed.state == OFF ) { // day time normal mode
            if( BULB12USMB_Brightness.state == 0.00000000 ) { // Lights ON
                MasterBedMotionProxy.sendCommand (ON)
                return;
            }
        if( BULB12USMB_Brightness.state != 0.00000000 ) { // Lights OFF
            MasterBedMotionProxy.sendCommand (OFF)
            return;
        }
        }
    }
    if( MbedSwitchWhat.state == "3002" ) { // Second Button
        if( PLUG9_Switch_MBED_EBlanket.state == ON ) {
            PLUG9_Switch_MBED_EBlanket.sendCommand ("OFF")
            bedroomblankettimer?.cancel
            logInfo("Amazon Dash.rules", "MB E-Blanket OFF (MB Dash Button)")
            return;
            }
        if( PLUG9_Switch_MBED_EBlanket.state == OFF ) {
            PLUG9_Switch_MBED_EBlanket.sendCommand ("ON")
            logInfo("Amazon Dash.rules", "MB E-Blanket ON (MB Dash Button)")
        }
    }
    if( MbedSwitchWhat.state == "2002" ) { // Third Button
        if( Plug2_Switch_MBED_Fan.state == ON ) {
            Plug2_Switch_MBED_Fan.sendCommand ("OFF")
            bedroomblankettimer?.cancel
            logInfo("Amazon Dash.rules", "MB FAN OFF (MB Dash Button)")
            return;
        }
        if( Plug2_Switch_MBED_Fan.state == OFF ) {
            Plug2_Switch_MBED_Fan.sendCommand ("ON")
            logInfo("Amazon Dash.rules", "MB FAN ON (MB Dash Button)") 
        }
    }
    if( MbedSwitchWhat.state == "1002" ) { // Top Button
        
    }
end

i needed the sleep at the top of the rule otherwise OH got confused too what button was pressed

the references from amazon dash is because i made a quick copy of the code from old dash buttons just noticed and needs too be changed :frowning:

@rlkoshak ok nice, thanks for your help.

@Sharpy well thx for the code and the offer :slight_smile:
The code does not seem to complicated so I should be able to get done what I have in mind :slight_smile:

And again to all of you, thanks for the quick help!

Edit: oh and @Sharpy because you just mentioned it: could you maybe tell me, how the HTTP binding works? Because I have two NodeMCUs running a webservice to switch a simple device on and off. This done by two urls (for example hhttp:///on or http:///off). Also there is one url where I can get the state of the device (on or off). Would it be possible for me to send a request to …/on or …/off and also somehow request the state by the url …/getState via the HTTP binding?

could you maybe tell me, what “Bed_Trigger” and “Morning_Mode_Ready” is?
Are these items or things?
Or do you know how longs variables are being kept? Like if I store a value to a var inside a rule, will the value of the state be available later on?

These are simple switch items I created in text files super simple and are not needed too use the dimmer switches they are only a part of my setup :slight_smile:

on my setup heres what they do

Bed trigger is a switch I use too tell openhab I’m going too bed so it can run a routine that turns off lights and sockets and arms my security system I use its state in that rule so it can run the end of the routine and turn off my bedroom light and also if this mode is on that im in bed and have requested my lights too turn on

Morning mode ready is the same it’s a simple switch that when on it waits for motion at the bottom of my stairs that then triggers the full morning mode routine turning lights on sockets on and disarm my security system

other.items

Switch   Bed_Trigger                         "Bed Trigger"
Switch   Morning_Mode_Ready        "Wait for morning Trigger"

That will be possible but I’m not sure how you use the http binding like I say I’m not an expert I only used it for the hue switches following instructions make a post on the fouroum somobody will help you with that :slight_smile:

                               **Adding Hue Dimmer Switches to OH**
  1. Add the dimmer switch too openhab using paperUI creating the thing only
  2. create the items in text files (copy and edit this too the items folder save as hue.items edit the channels at the end of the items too match the ones listed in the thing on paperUI
Number KitSwitchWhat "Kitchen Switch Button [%s]"                                                {channel="hue:0820:001788781cca:57:dimmer_switch" }
DateTime KitSwitchWhen "Kitchen Switch When [%s]"                                                 {channel="hue:0820:001788781cca:57:last_updated" }
Number KitSwitchBattery "Kitchen Switch Battery [%.0f %%]"              {channel="hue:0820:001788781cca:57:battery_level"}

the channels at the end of the item files are listed on the thing on paperUI marked in a square you can just copy them using copy marked with a circle saves alot of typing and mistakes

{channel="hue:0820:001788781cca:57:dimmer_switch" }

  1. create the rule in text files (copy and edit this too the rules folder save as hue.rules edit the rule so it does what you want
rule "Dimmer Switch Rule"
when
    Item KitSwitchWhen changed
then
Thread::sleep(1500) // wait too not confuse OH
    if( KitSwitchWhat.state == 4002.0  ) { // Bottom Button
        // put stuff you want it too do here
    }
    if( KitSwitchWhat.state == 3002.0 ) { // Second Button
        // put stuff you want it too do here
    }
    if( KitSwitchWhat.state == 2002.0 ) { // Third Button
        // put stuff you want it too do here
    }
    if( KitSwitchWhat.state == 1002.0 ) { // Top Button
        // put stuff you want it too do here
    }
end
2 Likes

well thanks again for the great help :slight_smile:

I will tinker with these sample a bit and see where this takes me.
Maybe I come back with more questions, I hope that is ok :smiley:

1 Like

@JustTotallyMe

Sorry there were a few errors in the rule i sent you hope it didnt cause you any problems

i have updated it now and fixed the issues should be fine now :slight_smile:

1 Like

Thanks a million, @Sharpy, for your approach! As a workaround, it helped me to fix a serious issue that prevented me from using my Hue dimmers as intended:

1 Like

Hi @miba no problem glad it helped you :slight_smile: