Meaning...?Madgeni wrote:async callbacks via the API call
New kind of Amazon Dash button to start tasks
Moderators: leecollings, remb0
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: RE: Re: New kind of Amazon Dash button to start tasks
-
- Posts: 1571
- Joined: Friday 25 March 2016 17:43
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: New kind of Amazon Dash button to start tasks
probably in the context of making one device call, not much. but node is built for asynchronicity, so good practice to not let your code block
Native Alexa skill and Google app - register at https://www.controlicz.com - https://twitter.com/Controlicz
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
thanks!!
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
ok so next question.. I have set this up and is working... How do I get the program to launch on boot of the Pi?
I'm a bit of a noob when it comes to the pi
I have checked rc.local but I cant see where Domoticz is stating on boot to I assume this is the wrong place.
Code: Select all
pi@raspberrypi:~/node_modules/node-dash-button $ sudo node node-dash.js
I have checked rc.local but I cant see where Domoticz is stating on boot to I assume this is the wrong place.
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
go it...
in the /etc/rc.local file I added the line. seems to have done the trick.
I did notice this created 2 processes:
Is this normal? do I need the sudo?
in the /etc/rc.local file I added the line. seems to have done the trick.
Code: Select all
sudo node /home/pi/node_modules/node-dash-button/node-dash.js &
Code: Select all
root 444 1 0 21:55 ? 00:00:00 sudo node /home/pi/node_modules/node-dash-button/node-dash.js
root 465 444 3 21:55 ? 00:00:04 node /home/pi/node_modules/node-dash-button/node-dash.js
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: New kind of Amazon Dash button to start tasks
I'm experiencing the same thing, i.e., 2 processes get created, one with sudo, one without:
I'm using @pdjm43's code (with my MAC addresses):
If I run this as
then the second process reverses the effect of the first, i.e., toggles the light back again!
Code: Select all
root 27739 0.0 0.3 6184 3092 pts/0 T 23:02 0:00 sudo node node-dash.js
root 27743 3.7 3.9 110804 37352 pts/0 Tl 23:02 0:02 node node-dash.js
Code: Select all
#!/usr/bin/env node
var dash_button = require('node-dash-button');
var dash = dash_button(["50:f5:da:38:e1:f0","ac:63:be:17:2f:4a"], null, null, 'arp'); //mac address from node-dash-button$
var requestify = require('requestify');
dash.on("detected", function (dash_id){
if (dash_id === "50:f5:da:38:e1:f0"){
console.log("Dash1");
requestify.get('http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=118&switchcmd=Toggle');
} else if (dash_id === "ac:63:be:17:2f:4a"){
console.log("Dash2");
requestify.get('http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=221&switchcmd=Toggle');
}
});
Code: Select all
nohup sudo node node-dash.js &
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
Mike,
I'll post my script later but I was thinking as an improvement to the script I am thinking about creating a dummy button for each dash button. so then when I have set it up initially I don't need to edit the file. From that I can just use the json queries in the on and off actions on that dummy button to kick off the relevant activity.
So this way you can then use the Domoticz GUI to edit everything.
I suppose you could go one step further and read an array of values from the Domoticz variables and then the script would be independent from the mac addresses and the IDX values.
Thoughts?
I'll post my script later but I was thinking as an improvement to the script I am thinking about creating a dummy button for each dash button. so then when I have set it up initially I don't need to edit the file. From that I can just use the json queries in the on and off actions on that dummy button to kick off the relevant activity.
So this way you can then use the Domoticz GUI to edit everything.
I suppose you could go one step further and read an array of values from the Domoticz variables and then the script would be independent from the mac addresses and the IDX values.
Thoughts?
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: New kind of Amazon Dash button to start tasks
Yes, I can see that this would be useful, although it's no great hardship to edit the script and add the MAC addresses and IDX's - this is only a one-time activity.
BTW, I was initially concerned about these becoming useless once the battery dies (I bought 2 used on eBay), but I have managed to carefully score around the join, and there is a Duracell AAA battery inside (and I've put it back together again!).
BTW, I was initially concerned about these becoming useless once the battery dies (I bought 2 used on eBay), but I have managed to carefully score around the join, and there is a Duracell AAA battery inside (and I've put it back together again!).
-
- Posts: 169
- Joined: Wednesday 30 September 2015 11:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8975
- Location: United Kingdom
- Contact:
Re: New kind of Amazon Dash button to start tasks
They are £5 each at Amazon (or free if you make one order) so in my view no need to be concerned. In theory one can change them every year.MikeF wrote:BTW, I was initially concerned about these becoming useless once the battery dies (I bought 2 used on eBay)
Thought your investigation comes very useful. Thank you.
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
Nice one on the battery. I wouldn't have thought it was a AAA inside even though I did think the device was a bit large. It will be interesting to see how long these last. I suspect this will very much depend on usage
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
My code calling a bunch of dummy switches which in turn run a json command to perform the aciton I want. this way I know when its a dash button thats turned something on as it will show in the dummy switch log
I used a case statement instead of a if else
I used a case statement instead of a if else
- Spoiler: show
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: New kind of Amazon Dash button to start tasks
Just bought two more of these on eBay - Andrex and Rimmel. Both registered OK with Amazon, but when I run findbutton and press the Rimmel button, I get
- also, the light glows yellow twice before the usual 5 sequences of red flashes. Is this a 'rogue' button, or do the yellow flashes mean low battery? (this is not mentioned on the Amazon help page: About the Indicator Light on Dash Button)
Separately, I've created a python routine using scapy, which seems to be simpler than the node.js version:
(Dash 2 runs a bash script which triggers a heating boost through my Hive Home Heating system.)
Code: Select all
Possible dash hardware address detected: 34:d2:70:29:a3:2a Manufacturer: unknown Protocol: udp
Possible dash hardware address detected: 34:d2:70:29:a3:2a Manufacturer: unknown Protocol: arp
Separately, I've created a python routine using scapy, which seems to be simpler than the node.js version:
Code: Select all
from scapy.all import *
import os
import requests
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].hwsrc == '50:f5:da:38:e1:f0': # ARP Probe
print "ARP Probe from: Dash 1 " + pkt[ARP].psrc
url = 'http://127.0.0.1:8080/json.htm?type=command¶m=switchlight&idx=136&switchcmd=Toggle'
r = requests.get(url)
if pkt[ARP].hwsrc == 'ac:63:be:17:2f:4a': # ARP Probe
print "ARP Probe from: Dash 2 " + pkt[ARP].psrc
os.system("bash /Users/mjf2708/HA/hive_boost.sh")
if pkt[ARP].hwsrc == 'ac:63:be:c8:84:93': # ARP Probe
print "ARP Probe from: Dash 3 " + pkt[ARP].psrc
# not yet allocated
if pkt[ARP].hwsrc == '34:d2:70:29:a3:2a': # ARP Probe
print "ARP Probe from: Dash 4 " + pkt[ARP].psrc
# not yet allocated
print sniff(prn=arp_display, filter="arp", store=0, count=0)
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: New kind of Amazon Dash button to start tasks
all you really care about is the MAC address so should work fine even if its a rogue button
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 350
- Joined: Sunday 19 April 2015 0:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2022.2
- Location: UK
- Contact:
Re: New kind of Amazon Dash button to start tasks
Agreed. I just wondered if anyone knew the significance of the LED flashing yellow?
-
- Posts: 7
- Joined: Wednesday 18 October 2017 16:36
- Target OS: -
- Domoticz version:
- Contact:
Re: New kind of Amazon Dash button to start tasks
Hello guys. I am trying to set this up as a doorbell can anyone guide me with that process or share their method.
I see that most implementations in this thread focus on switch items on and off, so was wondering how to get it to lay a sound or tts when pushed.
I see that most implementations in this thread focus on switch items on and off, so was wondering how to get it to lay a sound or tts when pushed.
Who is online
Users browsing this forum: No registered users and 1 guest