Re: [mh] MQTT functionality

Paul Voyer <[email protected]>
Newsgroups gmane.comp.misc.misterhouse.user
Message-ID <DM6PR08MB57864064EA9D19E97B22E98EC80F0@DM6PR08MB5786.namprd08.prod.outlook.com>
Hi Dean!

After reading your latest email I realized that my mqtt.mht was wrong...
And then I changed it and now MH this is working as expected:
######################
Format = A
# MQTT stuff
# noloop=start
CODE, require mqtt;
        #
CODE, $mqtt1 = new mqtt('mqtt_1', '127.0.0.1', 1883, '#', "", "", 122);

CODE, $Sonoff_HT16_1     = new mqtt_Item($mqtt1, 'cmnd/Sonoff_HT16_1/POWER');
CODE, $Sonoff_S31_1      = new mqtt_Item($mqtt1, 'cmnd/Sonoff_S31_1/POWER');
CODE, $Sonoff_Basic_1    = new mqtt_Item($mqtt1, '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($mqtt1, 'cmnd/Sonoff_CEsmart_2/POWER');

CODE, $Sonoff_HT16_1->set_states('on','off','On','Off','ON','OFF');
CODE, $Sonoff_S31_1->set_states('on','off','On','Off','ON','OFF');
CODE, $Sonoff_Basic_1->set_states('on','off','On','Off','ON','OFF');
CODE, $Sonoff_CEsmart_1->set_states('on','off','On','Off','ON','OFF');
CODE, $Sonoff_CEsmart_2->set_states('on','off','On','Off','ON','OFF');
#######################
Now I just need to add my sensors ...

Thanks,
________________________________
De : Dean Junk <[email protected]>
Envoyé : 12 mai 2019 16:43
À : [email protected]
Objet : Re: [mh] MQTT functionality

Ok, after creating a generic object on MH side, only the publish is working. When I turn the object on in MH, it publishes the command correctly. When I turn the object off in the zwave software, MH reads the command, but doesn't set the state of the object. I think it is because it doesn't know the right object to set in MH. The $self->get_object_name() is undefined in the set function...

When I originally tested, I could see the object get set correctly in zwave software, but didn't have an object in MH to view the status in the opposite direction. I was watching the log and the log indicated that both were happening correctly (sub and pub).

Thanks!

Dean
On 5/10/19 10:20 PM, Dean Junk wrote:
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

________________________________________________________
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.