rtttl play on mqtt message?

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

rtttl play on mqtt message?

#1 Post by rene9900 » 07 Mar 2018, 23:29

im playing around with the PLUGIN_BUILD_TESTING version and made it play starwars theme when i push a button <3
thats awsome, i know :D
but i wanted to make a doorbell so the button is located on a esp8266 at the front door, and when pushed it send a mqtt topic so the unit
with the buzzer play the tune, but i can not wrap my head around it and figure out how to send the RTTTL command like that?

i tried
on systemboot do
rtttl,14:d=4,o=5,b=180:8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6,p,8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6

and it works, locally on the buzzer unit, but i still can't make it pickup a mqtt,
i also tried the http command and it play only a few beeps then it stops again

any ideas? :ugeek:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rtttl play on mqtt message?

#2 Post by toffel969 » 08 Mar 2018, 07:51

rene9900 wrote: 07 Mar 2018, 23:29 im playing around with the PLUGIN_BUILD_TESTING version and made it play starwars theme when i push a button <3
thats awsome, i know :D
but i wanted to make a doorbell so the button is located on a esp8266 at the front door, and when pushed it send a mqtt topic so the unit
with the buzzer play the tune, but i can not wrap my head around it and figure out how to send the RTTTL command like that?

i tried
on systemboot do
rtttl,14:d=4,o=5,b=180:8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6,p,8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6

and it works, locally on the buzzer unit, but i still can't make it pickup a mqtt,
i also tried the http command and it play only a few beeps then it stops again

any ideas? :ugeek:
Make an event in rules that contains the rttl sequence, then trigger that event by http/mqtt

On music do
Rttl,.........your sequence
Endon

To trigger
http://<espeasyip>/control?cmd=event,Music

Not sure if mqtt also works,
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#3 Post by rene9900 » 08 Mar 2018, 08:36

cool your rule works perfect, so does the trigger, then i just need to make another esp send a trigger when doorbell is pushed
i tried via node-red to "translate" a message to the http trigger, but it wont work.
seems odd to me if a rule cant be triggered by mqtt?

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rtttl play on mqtt message?

#4 Post by toffel969 » 08 Mar 2018, 08:40

I don't use mqtt, and know little to nothing about it..
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#5 Post by grovkillen » 08 Mar 2018, 09:14

How do you send the mqtt command? Please give us the topic and payload.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#6 Post by rene9900 » 08 Mar 2018, 09:32

grovkillen wrote: 08 Mar 2018, 09:14 How do you send the mqtt command? Please give us the topic and payload.
i didnt because i couldnt make it work :lol:

i used toffels969's advice and
by a switch button and some rules, its HTTP cmd, i dont know if thats why it has like 1 sec delay on press??

//Doorbell
//Sender esp
On Switch#Switch=1 do
SendToHTTP 192.168.1.100,/control?cmd=event,Music
Endon

//Reciever ESP
On Music do
rtttl,14:d=4,o=5,b=180:8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6,p,8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8c6,2a#.6,f.6,8d#6,8d6,8d#6,2c6
Endon

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#7 Post by grovkillen » 08 Mar 2018, 10:05

I'm not asking for help. I want to help you. The syntax of mqtt cmd is this:

Topic

Code: Select all

<MQTT subscribe template>/cmd
Payload

Code: Select all

event,<eventName>
As stated here: https://www.letscontrolit.com/wiki/inde ... _Reference

Regarding the delay, what's your setting for "message delay" found in the advanced page? Default is 1000ms, but for devices with switch input its recommended to set this to 100ms.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#8 Post by rene9900 » 08 Mar 2018, 10:14

I have set it to 250ms same delay, but its bearable 🤣
987BB6FC-C8E0-4425-BDA8-C97015434847.png
You do not have the required permissions to view the files attached to this post.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#9 Post by grovkillen » 08 Mar 2018, 10:16

NTP enabled but no host?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#10 Post by rene9900 » 08 Mar 2018, 12:50

Yes i guess it use my router time server, only Way i could make time work was 60 and no server

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: rtttl play on mqtt message?

#11 Post by Domosapiens » 08 Mar 2018, 14:15

@Mr Wiki Grovkillen ;)
NTP Hostname Can be left empty as it defaults to pool.ntp.org. Can be changed here if needed.
https://www.letscontrolit.com/wiki/inde ... _interface
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#12 Post by grovkillen » 08 Mar 2018, 14:26

Domosapiens wrote: 08 Mar 2018, 14:15 @Mr Wiki Grovkillen ;)
NTP Hostname Can be left empty as it defaults to pool.ntp.org. Can be changed here if needed.
https://www.letscontrolit.com/wiki/inde ... _interface
Aaah :lol: Thanks!
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#13 Post by rene9900 » 09 Mar 2018, 10:29

grovkillen wrote: 08 Mar 2018, 10:05 I'm not asking for help. I want to help you. The syntax of mqtt cmd is this:

Topic

Code: Select all

<MQTT subscribe template>/cmd
Payload

Code: Select all

event,<eventName>
As stated here: https://www.letscontrolit.com/wiki/inde ... _Reference

Regarding the delay, what's your setting for "message delay" found in the advanced page? Default is 1000ms, but for devices with switch input its recommended to set this to 100ms.
i have been trying this template, but i dont understand it i guess :( how do i make a esp send a mqtt cmd on button press, and then make a second esp grab the command and then execute the rule set?
am i supposed to change anything in controller setup as it is now it listen for %sysname%# in subscripe which i guess is ok?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#14 Post by grovkillen » 09 Mar 2018, 10:56

You need to use rules and trigger "publish" on button unit.

Code: Select all

Publish <name of second unit >/cmd,event,<eventName>
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#15 Post by rene9900 » 09 Mar 2018, 11:10

grovkillen wrote: 09 Mar 2018, 10:56 You need to use rules and trigger "publish" on button unit.

Code: Select all

Publish <name of second unit >/cmd,event,<eventName>

ah i get it...using mqtt spy to make sure its not the esp sender that makes a mess
Skærmbillede 2018-03-09 kl. 11.07.47.png
log goes like this
MQTT : Topic: GUL/cmd
MQTT : Payload: event,Music
EVENT: Music
ACT : rtttl,14:d=4,o=5,b=180:8f,8f,8f,2a#.,2f.6,8d#6,8d6,8c6,2a#.6,f


i guess on sender esp the rule go like this?
On Switch#Switch=1 do
Publish GUL/cmd,event,Music
Endon

i had a rule not disabled properly with 2 // but only 1 when i added the second / it worked, THANK YOU for once again saving my hair from beeing ripped out by its roots :D
You do not have the required permissions to view the files attached to this post.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#16 Post by grovkillen » 09 Mar 2018, 11:13

Happy to have helped. :)

And the rule you posted seems all right.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#17 Post by rene9900 » 10 Mar 2018, 21:16

grovkillen wrote: 09 Mar 2018, 11:13 Happy to have helped. :)

And the rule you posted seems all right.
one last question :)
how come when i reboot my unit it plays the tune in rules that only is supposed to play on either button press on the unit or by the remote sender unit?

my ruleset looks like this:

On Switch#Switch=1 do
Publish ROSENQUIST/cmd,event,Music
gpio 12,1 //blå led
//delay 2000
gpio 12,0
Endon

On Music do
rtttl,14:d=4,o=5,b=180:8f,8f,8f,2a# //made shorter to avoid wife anger while testing :)
endon

TD-er
Core team member
Posts: 9917
Joined: 01 Sep 2017, 22:13
Location: the Netherlands

Re: rtttl play on mqtt message?

#18 Post by TD-er » 10 Mar 2018, 21:54

Maybe the pin value is somehow changed?
Either by booting (activating pull-up) or receiving the setting from an external source?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#19 Post by grovkillen » 10 Mar 2018, 22:18

Psy0rz told me the rtttl code is not stable at all. You can even get it in a endless loop as I describe here:

https://github.com/letscontrolit/ESPEasy/issues/446

I think we need to remove the hashtag (#) from the tune code, it might trigger some rules by mistake? I mean in the command execution internally and not in your tune.

Maybe use @ instead?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#20 Post by rene9900 » 10 Mar 2018, 23:04

grovkillen wrote: 10 Mar 2018, 22:18 Psy0rz told me the rtttl code is not stable at all. You can even get it in a endless loop as I describe here:

https://github.com/letscontrolit/ESPEasy/issues/446

I think we need to remove the hashtag (#) from the tune code, it might trigger some rules by mistake? I mean in the command execution internally and not in your tune.

Maybe use @ instead?
so i should try change rtttl code replace # with @?
EDIT: if i reboot my PI that runs mosquitto server it also plays the tune

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: rtttl play on mqtt message?

#21 Post by toffel969 » 11 Mar 2018, 08:52

rene9900 wrote: 10 Mar 2018, 23:04
grovkillen wrote: 10 Mar 2018, 22:18 Psy0rz told me the rtttl code is not stable at all. You can even get it in a endless loop as I describe here:

https://github.com/letscontrolit/ESPEasy/issues/446

I think we need to remove the hashtag (#) from the tune code, it might trigger some rules by mistake? I mean in the command execution internally and not in your tune.

Maybe use @ instead?
so i should try change rtttl code replace # with @?
EDIT: if i reboot my PI that runs mosquitto server it also plays the tune
For curiosity, try to disable the mqtt retain flag under adavanced tab and see if it still behaves the same
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#22 Post by grovkillen » 11 Mar 2018, 08:59

rene9900 wrote: 10 Mar 2018, 23:04 so i should try change rtttl code replace # with @?
No no, I'm talking about source code. You cannot do anything about it until rtttl is more stable.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

rene9900
Normal user
Posts: 28
Joined: 25 Apr 2017, 11:47

Re: rtttl play on mqtt message?

#23 Post by rene9900 » 12 Mar 2018, 08:44

i gotten rid of the play on reboot by changing the event,Music to event,Music#1
now i can reboot the mqtt server or it can lose wifi, and i can reboot my esp8266 safely.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden

Re: rtttl play on mqtt message?

#24 Post by grovkillen » 12 Mar 2018, 08:45

Now that is something to report to Github. Will you do it?

EDIT: I attached a link to this thread to the issue #446.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Who is online

Users browsing this forum: Ahrefs [Bot], Anthropic Claude Bot [bot], Bing [Bot] and 17 guests