Compare commits
7 Commits
2.0.1
...
2.0.9-conf
| Author | SHA1 | Date | |
|---|---|---|---|
|
6796bdd905
|
|||
|
6c208e32bf
|
|||
|
d2ee8a80c2
|
|||
|
5e0127b571
|
|||
|
311d4cf555
|
|||
|
ad043b5921
|
|||
|
7c90962de1
|
@@ -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
|
||||
@@ -228,3 +230,17 @@ output:
|
||||
register_type: input
|
||||
data_type: float32
|
||||
adaptor: floatAdaptor
|
||||
- name: car_feedback
|
||||
enabled: true
|
||||
publish_topic: IoT/Car/Feedback/State
|
||||
scan_rate: 1
|
||||
raw_output: true # use only for output device with only one register, name this register 'output'
|
||||
slave_id: 7
|
||||
registers:
|
||||
- address: 0x0010
|
||||
attribute: output
|
||||
name: State
|
||||
unit: "-"
|
||||
register_type: holding
|
||||
data_type: int32
|
||||
adaptor: onOffAdaptor
|
||||
|
||||
@@ -9,7 +9,7 @@ def floatAdaptor(i):
|
||||
return float(f"{i:0.2f}") if i else 0.0
|
||||
|
||||
def onOffAdaptor(i):
|
||||
return bool(i)
|
||||
return 'on' if bool(i) else 'off'
|
||||
|
||||
|
||||
|
||||
@@ -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