mqq instead of http to control pwm

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

mqq instead of http to control pwm

#1 Post by megamarco83 » 08 Jan 2019, 21:45

hi now i'm controlling pmw leds using commands like:
http://192.168.0.155/control?cmd=PWM,0,100
http://192.168.0.155/control?cmd=PWM,0,500
http://192.168.0.155/control?cmd=PWM,0,0
etc...
now is it possible to move from http to mosquitto?
what's are the command that i have to send to esp?
thanks so much!

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

Re: mqq instead of http to control pwm

#2 Post by grovkillen » 08 Jan 2019, 22:36

Commands are the same. See here: https://espeasy.readthedocs.io/en/lates ... mmand.html

Topically you have this type of subscribed incoming topic:
%sysname%/#

Given that your units name is Hulk you would command it by sending the commands to this topic:
Hulk/cmd
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:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#3 Post by megamarco83 » 19 Feb 2019, 21:08

grovkillen wrote: 08 Jan 2019, 22:36 Commands are the same. See here: https://espeasy.readthedocs.io/en/lates ... mmand.html

Topically you have this type of subscribed incoming topic:
%sysname%/#

Given that your units name is Hulk you would command it by sending the commands to this topic:
Hulk/cmd
sorry but i try this:
http comands=
http://192.168.0.155/control?cmd=PWM,0,400,1900
and it works perfectly

now my esp name is: wemos_155

so from shell i send the commands:

mosquitto_pub -t wemos_155 -m PWM,0,400,1900

but my light is now light on now, why?
thanks

p.s. i'm using mega-20190202
Last edited by megamarco83 on 19 Feb 2019, 21:54, edited 1 time in total.

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

Re: mqq instead of http to control pwm

#4 Post by grovkillen » 19 Feb 2019, 21:42

Try this:

Code: Select all

mosquitto_pub -t wemos_155/cmd -m PWM,0,400,1900
mosquitto_pub -t wemos_155/cmd -m PWM,0,400,1900
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:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#5 Post by megamarco83 » 19 Feb 2019, 21:51

hi, i tested but still not working

i open two shell in putty
1) just to see what i receive with commands:

Code: Select all

sudo mosquitto_sub -F "%U - %t - %p" -v -t  'wemos_155'
2)second shell to send commands:

Code: Select all

sudo mosquitto_pub -t wemos_155/cmd -m PWM,0,400,1900
but if i use that command i see nothing inside the shell 1)

if i use the command:

Code: Select all

sudo mosquitto_pub -t wemos_155 -m PWM,0,400,1900
i see the answer:

Code: Select all

pi@raspberrypi:~ $ sudo mosquitto_sub -F "%U - %t - %p" -v -t  'wemos_155'
1550609391.736067818 - wemos_155 - PWM,0,400,1900

it seams that if i send a command that contain the / in the shell 1) i can see the topic received
p.s. i'm using mega-20190202

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#6 Post by megamarco83 » 19 Feb 2019, 22:10

grovkillen wrote: 19 Feb 2019, 21:42 Try this:
need to set somethin in the options?
Screenshot_2019-02-19 wemos155.png
Screenshot_2019-02-19 wemos155.png (34.91 KiB) Viewed 7827 times
Screenshot_2019-02-19 wemos155(1).png
Screenshot_2019-02-19 wemos155(1).png (62.9 KiB) Viewed 7827 times

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

Re: mqq instead of http to control pwm

#7 Post by grovkillen » 20 Feb 2019, 05:42

With your settings you would need to use this:

mosquitto_pub -t domoticz/out/cmd -m PWM,0,400,1900

But that would make all units fetch that command since they all listen to that topic?

I'm not familiar with Domoticz enough to help you out but I would first try to change the subscribe topic to %sysname%/# and see if everything still works alright.
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:

wim16
Normal user
Posts: 88
Joined: 01 May 2017, 20:35

Re: mqq instead of http to control pwm

#8 Post by wim16 » 20 Feb 2019, 08:42

@megamarco83: You should use an MQTT-helper device in which you specify the idx of the device in Domoticz.
If you define a dimmer in Domoticz the MQTT-helper even changes pwm according to Domoticz percentage.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#9 Post by megamarco83 » 20 Feb 2019, 08:49

Screenshot_2019-02-20 wemos_155.png
Screenshot_2019-02-20 wemos_155.png (15.88 KiB) Viewed 7800 times
i set as you suggest the mqtt topic
but i'm not able to send mqtt message.
i try your suggestion and others try but withou success.
name of my esp = wemos_155
this is the shell to listen with commands:

Code: Select all

sudo mosquitto_sub -F "%U - %t - %p" -v -t  'wemos_155'
listern.jpg
listern.jpg (11.71 KiB) Viewed 7800 times
this is the shell where i try to send commands:
send.jpg
send.jpg (59.97 KiB) Viewed 7800 times
as you can see it seams that esp is able to receive only topic send to wemos_155 if i add a "/" the comand is not received and showed in the shell 1) that was supposed to listen

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#10 Post by megamarco83 » 20 Feb 2019, 08:56

wim16 wrote: 20 Feb 2019, 08:42 @megamarco83: You should use an MQTT-helper device in which you specify the idx of the device in Domoticz.
If you define a dimmer in Domoticz the MQTT-helper even changes pwm according to Domoticz percentage.
Screenshot_2019-02-20 wemos_155(1).png
Screenshot_2019-02-20 wemos_155(1).png (13.71 KiB) Viewed 7799 times
i create the device that is named test and i put the idx of my light in domoticz
now how i can control with mqtt?
what's the command?
the Controller Subscribe: required now to set as:

Code: Select all

 domoticz/out 
or

Code: Select all

 %sysname%/# 
?
thanks

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#11 Post by megamarco83 » 20 Feb 2019, 23:33

grovkillen wrote: 20 Feb 2019, 05:42 With your settings you would need to use this:

mosquitto_pub -t domoticz/out/cmd -m PWM,0,400,1900

But that would make all units fetch that command since they all listen to that topic?

I'm not familiar with Domoticz enough to help you out but I would first try to change the subscribe topic to %sysname%/# and see if everything still works alright.
hi grovkillen
finally i succeed on it.
the correct command is:

Code: Select all

sudo mosquitto_pub -t /wemos_155/cmd -m pwm,0,400,1900
but the important thin is to set as controller openhab and put as controller subscrive: /%sysname%/#
i try to set as controller domoticz mqtt and put as controller subrive the same as openhab: /%sysname%/#
but it not work!!!
is it possible to correct this bug?
i need domoticz mqtt....
thanks

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

Re: mqq instead of http to control pwm

#12 Post by grovkillen » 21 Feb 2019, 05:33

Yes I guess that could be considered a bug. Please open a new issue on GitHub.
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:

wim16
Normal user
Posts: 88
Joined: 01 May 2017, 20:35

Re: mqq instead of http to control pwm

#13 Post by wim16 » 21 Feb 2019, 08:27

You must keep subscribe topic to domoticz/out because that is the topic domoticz is publishing to.

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: mqq instead of http to control pwm

#14 Post by megamarco83 » 21 Feb 2019, 09:21

grovkillen wrote: 21 Feb 2019, 05:33 Yes I guess that could be considered a bug. Please open a new issue on GitHub.
open issue #2341
thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests