add MQTT component configuration; add MQTT origin
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
import struct, json, logging
|
import struct, json, logging, os
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Infos:
|
class Infos:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.db = {}
|
self.db = {}
|
||||||
|
self.app_name = os.getenv('SERVICE_NAME', 'proxy')
|
||||||
|
self.version = os.getenv('VERSION', 'unknown')
|
||||||
self.tracer = logging.getLogger('data')
|
self.tracer = logging.getLogger('data')
|
||||||
|
|
||||||
__info_devs={
|
__info_devs={
|
||||||
@@ -125,6 +127,10 @@ class Infos:
|
|||||||
#check if we have details for home assistant
|
#check if we have details for home assistant
|
||||||
if 'ha' in row:
|
if 'ha' in row:
|
||||||
ha = row['ha']
|
ha = row['ha']
|
||||||
|
if 'comp' in ha:
|
||||||
|
component = ha['comp']
|
||||||
|
else:
|
||||||
|
component = 'sensor'
|
||||||
attr = {} # dict to collect all the sensor entity details
|
attr = {} # dict to collect all the sensor entity details
|
||||||
if 'name' in ha:
|
if 'name' in ha:
|
||||||
attr['name'] = ha['name'] # take the entity name from the ha dict
|
attr['name'] = ha['name'] # take the entity name from the ha dict
|
||||||
@@ -173,13 +179,13 @@ class Infos:
|
|||||||
dev['ids'] = [f"{ha['dev']}_{snr}"]
|
dev['ids'] = [f"{ha['dev']}_{snr}"]
|
||||||
attr['dev'] = dev
|
attr['dev'] = dev
|
||||||
|
|
||||||
#origin = {}
|
origin = {}
|
||||||
#origin['name'] = 'org name'
|
origin['name'] = self.app_name
|
||||||
#origin['sw'] = 'Version Test'
|
origin['sw'] = self.version
|
||||||
#attr['o'] = origin
|
attr['o'] = origin
|
||||||
|
|
||||||
|
|
||||||
yield json.dumps (attr), attr['uniq_id']
|
yield json.dumps (attr), component, attr['uniq_id']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user