flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
465 stars 157 forks source link

CONFIG_SCHEMA is missing payload defaults in digital_outputs node #159

Closed robbyb67 closed 3 years ago

robbyb67 commented 3 years ago

Describe the bug Runtime error occurs in logging message if payload_on and payload_off are not configured for digital outputs

Expected behavior "ON" and "OFF" should be used as default payload for digital outputs when nothing is configured.

Error messages and traceback

(ERROR): Exception while handling received MQTT message:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pi_mqtt_gpio/server.py", line 528, in on_msg
    handle_set(topic_prefix, msg)
  File "/usr/local/lib/python2.7/dist-packages/pi_mqtt_gpio/server.py", line 221, in handle_set
    if payload not in (output_config["on_payload"], output_config["off_payload"]):
KeyError: 'on_payload'

Config

  host: mqtt
  port: 1883
  client_id: pi-mqttXXX
  user: ""
  password: ""
  topic_prefix: /oh3/

gpio_modules:
  - name: piface
    module: piface2

digital_inputs:
  - name: carport_contact
    module: piface
    pin: 7

digital_outputs:
  - name: carport_close_trigger
    module: piface
    pin: 7

Hardware

System:

Additional context I think there are simply two lines missing in init.py: default "ON" between 264/265 default "OFF" between 268/269

flyte commented 3 years ago

Oh! That looks like a regression. I guess it was caused by a merge somewhere and we didn't spot it.

Thanks!