Re: [mh] MQTT functionality

Dean Junk <[email protected]>
Newsgroups gmane.comp.misc.misterhouse.user
Message-ID <BN7PR03MB44358B0CCA12E08CCBF93316D10D0@BN7PR03MB4435.namprd03.prod.outlook.com>
After playing around with it a bit, I got it to work:) (Had to add the set to the end of the topic when defining the item)

My mqtt.pl file:

#noloop=start

require mqtt;

my $mqtt_server='192.168.0.135';
my $mqtt_port=1883;
my $mqtt_alive=122;

my $mqtt_office = new mqtt('officePlug', $mqtt_server, $mqtt_port, 'home/office/#', "", "", $mqtt_alive);

my $office_plug = new mqtt_Item($mqtt_office, "home/office/officePlug/set");
$office_plug->set_states('on','off','On','Off','ON','OFF');

my $office_plug_left = new mqtt_Item($mqtt_office, "home/office/officePlugLeft/set");
$office_plug_left->set_states('on','off','On','Off','ON','OFF');

my $office_plug_right = new mqtt_Item($mqtt_office, "home/office/officePlugRight/set");
$office_plug_right->set_states('on','off','On','Off','ON','OFF');

$office_plug->set("on");
$office_plug_left->set("on");
$office_plug_right->set("on");

#noloop=stop

Linux Fedora mosquitto command line that works:
mosquitto_pub -h 192.168.0.135 -t home/office/officePlug/set -m "on"
mosquitto_pub -h 192.168.0.135 -t home/office/officePlugLeft/set -m "on"
mosquitto_pub -h 192.168.0.135 -t home/office/officePlugRight/set -m "on"

On 5/10/19 7:57 PM, Paul Voyer wrote:
Funny! Because in my case, it is the reverse, Mister House can send (Publish) command to trun the light ON or OFF but is not able to know the status (Subscribe). It must to be something wrong in my setup!

Here is how my mqtt.mht is looking.
In your case, you are probably missing this type of information...
################################################################
Format = A
# MQTT stuff
# noloop=start
CODE, require mqtt;

CODE, $mqtt1 = new mqtt('mqtt_1', '127.0.0.1', 1883, 'cmnd/Sonoff_CEsmart_1/#', "", "", 121);
CODE, $mqtt2 = new mqtt('mqtt_2', '127.0.0.1', 1883, 'cmnd/Sonoff_CEsmart_2/#', "", "", 121);
CODE, $mqtt3 = new mqtt('mqtt_3', '127.0.0.1', 1883, 'cmnd/Sonoff_Basic_1/#', "", "", 121);
CODE, $mqtt4 = new mqtt('mqtt_4', '127.0.0.1', 1883, 'cmnd/Sonoff_S31_1/#', "", "", 121);
CODE, $mqtt5 = new mqtt('mqtt_5', '127.0.0.1', 1883, 'cmnd/Sonoff_HT16_1/#', "", "", 121);

CODE, $Sonoff_HT16_1     = new mqtt_Item($mqtt5, 'cmnd/Sonoff_HT16_1/POWER');
CODE, $Sonoff_S31_1      = new mqtt_Item($mqtt4, 'cmnd/Sonoff_S31_1/POWER');
CODE, $Sonoff_Basic_1    = new mqtt_Item($mqtt3, 'cmnd/Sonoff_Basic_1/POWER');
CODE, $Sonoff_CEsmart_1  = new mqtt_Item($mqtt1, 'cmnd/Sonoff_CEsmart_1/POWER');
CODE, $Sonoff_CEsmart_2  = new mqtt_Item($mqtt2, 'cmnd/Sonoff_CEsmart_2/POWER');

# noloop=stop
#################################################################

I am using mosquitto broker...

I know I am missing something to get the Switch State... But What!

In your case, you are probably missing this information...



________________________________
De : Dean Junk <[email protected]><mailto:[email protected]>
Envoyé : 10 mai 2019 17:30
À : Paul Voyer; The main list for the MisterHouse home automation program
Objet : Re: MQTT functionality

Are you publishing events or only subscribing? It looks like the subscribe works, but the publish does not. So when I set the MH object on, it should publish an event to MQTT topic to turn on the device. That isn't working. I can get it to wotk from the command line using the MQTT client on linux, but not from misterhouse.

On 5/10/19 8:34 AM, Paul Voyer wrote:
Hi Dean,

I could make it working but it took me sometime to figure out. Even now, I am not sure that I have it setup properly. And as of now I am adding a lot of new switches and sensors MQTT based, I am really interested in having it running the right way.
As I received recommendations from a Mister House guru (I think it was Lieven)... Create a script in mh/local/code and do some tests, with a lot of print_log. This how I could make it working.
Let me know if that helped.

Paul

Télécharger Outlook pour Android<https://aka.ms/ghei36>

________________________________
From: Dean Junk <[email protected]><mailto:[email protected]>
Sent: Friday, May 10, 2019 7:13:25 AM
To: The main list for the MisterHouse home automation program
Subject: [mh] MQTT functionality

I'm trying to integrate z-wave (razberry + zway) into misterhouse using
MQTT. I can subscribe/publish using Linux mosquito client successfully.
When I tried to invoke the MQTT functionality in misterhouse, I get
several errors related to undefined objects and such. It looks like it
kind of works for reading but the set does not work at all.

Anyone have this working? Any handy tips?

Thanks!

Dean


________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users

________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.