Page 1 of 1
mqq instead of http to control pwm
Posted: 08 Jan 2019, 21:45
by megamarco83
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!
Re: mqq instead of http to control pwm
Posted: 08 Jan 2019, 22:36
by grovkillen
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
Re: mqq instead of http to control pwm
Posted: 19 Feb 2019, 21:08
by megamarco83
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
Re: mqq instead of http to control pwm
Posted: 19 Feb 2019, 21:42
by grovkillen
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
Re: mqq instead of http to control pwm
Posted: 19 Feb 2019, 21:51
by megamarco83
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
Re: mqq instead of http to control pwm
Posted: 19 Feb 2019, 22:10
by megamarco83
need to set somethin in the options?
- Screenshot_2019-02-19 wemos155.png (34.91 KiB) Viewed 7911 times
- Screenshot_2019-02-19 wemos155(1).png (62.9 KiB) Viewed 7911 times
Re: mqq instead of http to control pwm
Posted: 20 Feb 2019, 05:42
by grovkillen
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.
Re: mqq instead of http to control pwm
Posted: 20 Feb 2019, 08:42
by wim16
@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.
Re: mqq instead of http to control pwm
Posted: 20 Feb 2019, 08:49
by megamarco83
- Screenshot_2019-02-20 wemos_155.png (15.88 KiB) Viewed 7884 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 (11.71 KiB) Viewed 7884 times
this is the shell where i try to send commands:
- send.jpg (59.97 KiB) Viewed 7884 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
Re: mqq instead of http to control pwm
Posted: 20 Feb 2019, 08:56
by megamarco83
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 (13.71 KiB) Viewed 7883 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:
or
?
thanks
Re: mqq instead of http to control pwm
Posted: 20 Feb 2019, 23:33
by megamarco83
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
Re: mqq instead of http to control pwm
Posted: 21 Feb 2019, 05:33
by grovkillen
Yes I guess that could be considered a bug. Please open a new issue on GitHub.
Re: mqq instead of http to control pwm
Posted: 21 Feb 2019, 08:27
by wim16
You must keep subscribe topic to domoticz/out because that is the topic domoticz is publishing to.
Re: mqq instead of http to control pwm
Posted: 21 Feb 2019, 09:21
by megamarco83
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