Hi Thomas,

It sounds like you should be using event.packet rather than event.record. 
Archive records are found in event.record, loop packets are found in 
event.packet. It's a subtle but important distinction. You have probably 
moved on from the code you posted above, and I probably should have 
mentioned it earlier, but I would avoid method names such as def 
new_archive_packet(). There is nothing wrong with using that name per se, 
but since we have loop packets and archive records it does tend to create a 
little confusion, something like  def new_archive_record() and def 
new_loop_packet() would be better.

Gary

On Friday, 5 October 2018 10:30:15 UTC+10, Thomas Carlin wrote:
>
> Hi Gary, 
>
> I've started working on this service, and I have run into an issue.  
>
> A quick refresher so you don't have to read through the whole thread:  I 
> am writing an MQTT service to add data to the loop packets.  You pointed me 
> in the right direction with the NEW_LOOP_PACKET, and I'm 99% of the way 
> there.  My service is pulling data with the loop packets, processing and 
> normalizing it, and I'm now to the point that I am ready to stuff it into 
> the loop packet.  
>
> Since I am modifying an existing service that I wrote, I am trying to use 
> the line event.record[key] = value. that I found in the documentation.  
> When I try this, I get the following trackback.  I'm sure that this is 
> because event.record is for archive packets, and I'm now working with 
> loop packets.
>
> Traceback (most recent call last):
>   File "/usr/bin/weewxd", line 64, in <module>
>     weewx.engine.main(options, args)
>   File "/usr/share/weewx/weewx/engine.py", line 877, in main
>     engine.run()
>   File "/usr/share/weewx/weewx/engine.py", line 191, in run
>     self.dispatchEvent(weewx.Event(weewx.NEW_LOOP_PACKET, packet=packet))
>   File "/usr/share/weewx/weewx/engine.py", line 224, in dispatchEvent
>     callback(event)
>   File "/usr/share/weewx/user/esp8266.py", line 105, in new_loop_packet
>     event.record[self.subscriptions[topic]] = value
> AttributeError: 'Event' object has no attribute 'record'
>
>
>
> Any thoughts on what I can do to correct this?  I have verified that the 
> variable self.subscriptions[topic] provides the expected value of 
> extraTemp1, and value contains 74.30.
>
> Also, related to this discussion, I would like to provide a simplified 
> version of code, and an explanatory blurb to be added to the documentation 
> to hopefully help others in a similar situation.  Is that something that 
> the development team would be open to?
>
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to