def schema(config): client = FroelingClient(config.port) schema = client.load_recent_values_schema() for s in schema: logging.info("{0} | Address: {1} | Unit: {2} | Factor: {3}".format( s['description'], fr_hex(s['address']), s['unit'], s['factor']))
def menu(config): client = FroelingClient(config.port) menu_entries = client.load_menu_structure() for m in menu_entries: logging.info( "{0} | Type: {1} | Address: {2} | Parent: {3} | Child: {4}".format( m['description'], m['type'], fr_hex(m['address']), fr_hex(m['parent']), fr_hex(m['child'])))
def errors(config): client = FroelingClient(config.port) errors = client.load_errors() for e in errors: t = datetime.fromtimestamp(e['timestamp']).isoformat() logging.info( "{0} | Number: {1} | State: {2} | Info: {3} | Timestamp: {4}". format(e['description'], e['number'], e['state'], e['info'], t))
def values(config): client = FroelingClient(config.port) schema = client.load_recent_values_schema() values = client.load_recent_values(schema) for address in values: s = list(filter(lambda x: fr_hex(x['address']) == address, schema)) if len(s) > 0: v = values[address] logging.info("{0} ({1}): {2}{3}".format(s[0]['description'], fr_hex(s[0]['address']), v, s[0]['unit']))
def query_data_and_submit(config): client = FroelingClient(config.port) # Load errors errors = client.load_errors() logging.info("Boiler errors loaded ({0})".format(len(errors))) # Load schema + values schema = client.load_recent_values_schema() logging.info("Value schemas loaded ({0})".format(len(schema))) values = client.load_recent_values(schema) logging.info("Boiler values loaded ({0})".format(len(values))) for s in schema: s['address'] = fr_hex(s['address']) # Load status info version = client.load_version_date() logging.info("Boiler version/date loaded") state = client.load_state() logging.info("Boiler state received") state['version'] = version['version'] # heating circuits logging.info("Load heating circuits info") hc = _heating_circuits_config_to_json(config.heating_circuits) digital_outputs = _load_digital_output( client, _find_digital_output_items(config.heating_circuits)) # host info logging.info("Load host info") host = host_info() data = { 'timestamp': int(time.time()), 'recent_values_schema': schema, 'recent_values': values, 'errors': errors, 'status': state, 'host_state': host, 'digital_outputs': digital_outputs, 'heating_circuits': hc } #print(json.dumps(data)) logging.info("Sending data to froeling.io") network = Network(config.device_token) network.send_data(data)
def gen_config(config): client = FroelingClient(config.port) menu = client.load_menu_structure() print_circuit_config(menu)
def date(config): client = FroelingClient(config.port) date = client.load_version_date() t = datetime.fromtimestamp(date['timestamp']).isoformat() logging.info("Version: {0} | Date: {1}".format(date['version'], t))
def state(config): client = FroelingClient(config.port) state = client.load_state() logging.info("Mode: {0} | State: {1}".format(state['mode'], state['state']))
def test_connection(config): client = FroelingClient(config.port) logging.info(client.test_connection())