This commit is contained in:
@@ -123,10 +123,11 @@ output:
|
||||
- name: pv_control
|
||||
publish_topic: IoT/PV/Control/State
|
||||
scan_rate: 1
|
||||
raw_output: true # use only for output device with only one register, name this register 'output'
|
||||
slave_id: 1
|
||||
registers:
|
||||
- address: 0x0001
|
||||
attribute: state
|
||||
attribute: output
|
||||
name: State
|
||||
unit: "-"
|
||||
register_type: holding
|
||||
@@ -136,10 +137,11 @@ output:
|
||||
enabled: true
|
||||
publish_topic: IoT/Car/Control/State
|
||||
scan_rate: 1
|
||||
raw_output: true # use only for output device with only one register, name this register 'output'
|
||||
slave_id: 5
|
||||
registers:
|
||||
- address: 0x0001
|
||||
attribute: state
|
||||
attribute: output
|
||||
name: State
|
||||
unit: "-"
|
||||
register_type: holding
|
||||
|
||||
@@ -49,12 +49,13 @@ class FromDevices(AbstractMqttPublisher):
|
||||
payload[registers.attribute] = value
|
||||
|
||||
payload['status'] = "Ok"
|
||||
payload['cnt'] = cnt
|
||||
|
||||
payloadStr = json.dumps(payload) if not device.raw_output else str(payload['output'])
|
||||
self.client.publish(device.publish_topic, payloadStr)
|
||||
logger.debug(f"mqtt message sent: {device.publish_topic} -> {payloadStr}")
|
||||
except Exception as e:
|
||||
logger.error(f"Caught exception: {str(e)}")
|
||||
|
||||
payload['cnt'] = cnt
|
||||
payloadStr = json.dumps(payload) if not device.raw_output else str(payload)
|
||||
self.client.publish(device.publish_topic, payloadStr)
|
||||
logger.debug(f"mqtt message sent: {device.publish_topic} -> {payloadStr}")
|
||||
|
||||
self.killEvent.wait(timeout=float(self.config.global_.scan_interval))
|
||||
|
||||
Reference in New Issue
Block a user