sensor: require the 'state_response_template'
The sensor configuration isn't useful unless the user configures a template that calls "set_result" to update fields for the desired template. Remove the default payload template and require that it be configured. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
90e13c07f7
commit
0850c16b00
|
@ -2837,7 +2837,7 @@ state_response_template:
|
|||
#
|
||||
# The above example assumes a json response with multiple fields in a struct
|
||||
# is received. Individual measurements are extracted from that struct, coerced
|
||||
# to a numeric format and passed to Moonraker. The default is the payload.
|
||||
# to a numeric format and passed to Moonraker. This parameter must be provided.
|
||||
```
|
||||
|
||||
!!! Note
|
||||
|
|
|
@ -116,7 +116,7 @@ class MQTTSensor(BaseSensor):
|
|||
self.mqtt: MQTTClient = self.server.load_component(cfg, "mqtt")
|
||||
|
||||
self.state_topic: str = cfg.get("state_topic")
|
||||
self.state_response = cfg.load_template("state_response_template", "{payload}")
|
||||
self.state_response = cfg.gettemplate("state_response_template")
|
||||
self.config = replace(self.config, source=self.state_topic)
|
||||
self.qos: Optional[int] = cfg.getint("qos", None, minval=0, maxval=2)
|
||||
|
||||
|
|
Loading…
Reference in New Issue