Accessing logged data in custom code


I am writing my first custom module (really largely based of @plord great SOC logging. I have a question though

I see the code uses to retrieve the soc data - cool good with that however given the fact that I also have a logger

def get_soc_display():
args = [‘soc’]
kwargs = {
‘mode’: ‘21’,
‘pid’: ‘05’,
‘header’: ‘7E4’,
‘baudrate’: 500000,
‘formula’: ‘bytes_to_int([33:34])’,
‘protocol’: ‘6’,
‘verify’: False,
‘force’: True,
return salt[‘obd.query’](*args, **kwargs)[‘value’]/2.0
return -1

however given the fact that I also have a logger set up querying the same data (i am actually not sure thesec are the same because i cant test at the sec) but you get the point

obd.query BBM mode=220 pid=105 header=7E4 bytes=54 formula=‘bytes_to_int([34:35])/2’ unit=% baudrate=500000 protocol=6 verify=false force=true
strong text

Is there not a way from within a custom module to query the BBM rather than duplicating the query ? It seems it would make the code a lot cleaner

I hope this makes sense - thanks in adavance

As I fumble my way through this, it is looking like there is no way to do it. (I think I saw a statement on one of the posts that it was not possible 12 months or so ago, I am working on the basis that this I the case.

My thinking is to use MQTT to publish all data that is called by the cloud returner onto a local bus with the last message posted to be retained. This would allow other custom code modules to simply subscribe to the bus on start up, retrieve the most recent value and do what they need to do.

To do this I have install the mqtt broker
I am creating a hook (of type returner) on the odd_manager service that will publish messages that are received.

The rate custom code modules as normal to retrieve and process data

A couple of questions. Is this a sensible approach , is there anything existing, does the pi zero have the process to do this ?


This topic was automatically closed 33 days after the last reply. New replies are no longer allowed.