This conversation might be better to continue in the weewx-development 
group. I am copying it over there.

Some imbedded comments below.



On Tuesday, 21 February 2017 06:06:40 UTC-4, wysiwyg wrote:
>
> Hello !
>
>
> *Regarding websockets: *
>
> Just found the howto I was talking about:
> http://www.frugalprototype.com/installation-de-votre-propre-broker-mqtt/
>
> it's in french (very convenient for me, sorrry guys ;-).
> But as a summary, it says the websocket function of mosquitto can be 
> enabled just with a small config file.
>
> I will try this (quick & easy to test).
>
> *Also, just to summarise my setup:*
> I just received last week a brand new Orange Pi PC plus (kind of low cost 
> raspberry which as a nice advantage imho: it has integrated emmc 8GB 
> memory).
> It is setup with Armbiam Ubuntu Xenial (server), v5.25.  (I am more 
> familiar to ubuntu so it's easier for me too)
> I just setup mosquitto from depot ( apt-get install mosquitto ).
> I setup weewx using the quick start guide with depot ( 
> http://www.weewx.com/docs/apt-get.htm )
>
> So it's all fresh install.
> I only modified mosquitto config to use "user/password" and play a bit 
> with weewx and wxMesh as you know.
>
>
> *finally, I have a general question regarding how the driver works:*
> let me know if my understanding is correct or wrong
>
> the "on_message" stuff is kind of asynchronous
> then when a message is available on the broker, this function will be 
> trigged  and will load the message content in payload.
>

Yes, when a message is received, the on_message callback is triggered.
 

>
> then the genLoopPackets is synchronous (I mean executed every n seconds, 
> n=poll interval defined in weewx.conf)
> So every n seconds, it checks if payload as some content and if yes, it 
> will process the data and deliver the "_packet" to next weewx process 
>
> Correct. I originally planned to build the loop packet in the on_message 
call back, but on_message actually runs in a separate thread I think, and I 
could not figure out how to easily get the data back to the weewx thread. 
 generating the loop packet only when a subscription arrives would be more 
efficient. I do not understand weewx or python quite well enough to design 
this yet.

>
> If this is correct, does it mean that if several mqtt messages are 
> delivered inside the n seconds interval, maybe only the last one will be 
> processed ?
>

I believe any number of "loop" packets can arrive within n seconds, 
especially for n>1. Read the Data Architecture section 
here: http://www.weewx.com/docs/customizing.htm


> The background of the question is that I'm thinking if it may be possible 
> to use a sub topic structure for mqtt
> The simplest idea I have in mind is to have: 
>  weather/<weewx_schemas_label>:
> weather/outTemp
> weather/outHumidity
> ....
>
>
> Then each of these topics may be sent at any time:  Temp, humidity, 
> barometer may be send only every few minutes.  Wind may be sent  every 1 or 
> few seconds,   rain may be send only when it's raining...
> weewx driver may subscribe to /weather/# to get them all and process 
> whenever they arrive ?
>
> -Ok- I speak but don't have a clue on how to do that :-) not sure it is 
> realistic.
>

That was exactly my original idea on how to build the driver. However, if a 
datum does not get set within the time interval of a RECORD (see the 
setting in the [StdArchive] section of weewx.conf), then it will be set to 
None, I think. I don't think this is what we want. Depending on the type of 
observation (wind, rain) we may want to keep the last value, or enter a 
zero.

wxMesh is definitely a work in progress. It may very well grow away from 
the original names


> The advantage could that it stick better to what I have seen from mqtt 
> usage, then same published topics could be used by other subscribers (
> home-assistant <https://home-assistant.io/>, automatic watering for the 
> garden or whatever)
>
> Best regards,
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Le mardi 21 février 2017 00:05:11 UTC+1, mwall a écrit :
>>
>> i found it helpful to configure the broker so that it publishes using 
>> websockets.  then you can use a web browser to see what is happening.  this 
>> is especially useful when you're trying to decode someone else's topic 
>> hierarchy, or to figure out why your own topics are not showing up where 
>> you think they should be.
>>
>> the hivemq folks wrote one of the first ones, which many people have now 
>> embedded:
>>
>> http://www.hivemq.com/blog/full-featured-mqtt-client-browser
>>
>> http://www.espert.io/mqtt/index.html
>>
>> but many other browser-based clients are out there:
>>
>> http://mitsuruog.github.io/what-mqtt/
>>
>> https://www.cloudmqtt.com/docs-websocket.html
>>
>> if you're using the mosquitto broker, you'll have to compile it with 
>> websocket compatibility.  but once you do that, enabling websockets is just 
>> a matter of making the broker listen on the websocket port.
>>
>> m
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to