Light.mqtt->on_command_type error

Hello,

In the last version of hassio (143) the option “on_command_type” seems broken:

I wrote, in the conf file:

on_command_type: ‘first’

…and got this error (which did not happen in the previous version):

2019-02-18 19:14:24 ERROR (MainThread) [homeassistant.config] Invalid config for [light.mqtt]: [on_command_type] is an invalid option for [light.mqtt]. Check: light.mqtt->on_command_type. (See /config/lights.yaml, line 0). Please check the docs at https://home-assistant.io/components/light.mqtt/

Is there a way to fix it?
Thanks

Please post the formatted configuration of the affected light. It may help provide clues as to why Home Assistant considers on_command_type to be invalid (despite it being a valid option).

BTW, I assume you used the correct quotes (' or ") to delimit first and not the ones shown in your post (‘first’).

Here’s the formatted code. I used correct quotes (") but the error remains…

light:
    - platform: mqtt
      schema: json
      name: "light_1"
      state_topic: "home/McLighting01-00E1332F_ha/state/out"
      command_topic: "home/McLighting01-00E1332F_ha/state/in"
      on_command_type: "first"
      effect: true
      effect_list:
       - "Static"
       - "Blink"
       - "Breath"
       - "Color Wipe"
       - "Color Wipe Inverse"
       - "Color Wipe Reverse"
       - "Color Wipe Reverse Inverse"
       - "Color Wipe Random"
       - "Random Color"
       - "Single Dynamic"
       - "Multi Dynamic"
       - "Rainbow"
       - "Rainbow Cycle"
       - "Scan"
       - "Dual Scan"
       - "Fade"
       - "Theater Chase"
       - "Theater Chase Rainbow"
       - "Running Lights"
       - "Twinkle"
       - "Twinkle Random"
       - "Twinkle Fade"
       - "Twinkle Fade Random"
       - "Sparkle"
       - "Flash Sparkle"
       - "Hyper Sparkle"
       - "Strobe"
       - "Strobe Rainbow"
       - "Multi Strobe"
       - "Blink Rainbow"
       - "Chase White"
       - "Chase Color"
       - "Chase Random"
       - "Chase Rainbow"
       - "Chase Flash"
       - "Chase Flash Random"
       - "Chase Rainbow White"
       - "Chase Blackout"
       - "Chase Blackout Rainbow"
       - "Color Sweep Random"
       - "Running Color"
       - "Running Red Blue"
       - "Running Random"
       - "Larson Scanner"
       - "Comet"
       - "Fireworks"
       - "Fireworks Random"
       - "Merry Christmas"
       - "Fire Flicker"
       - "Fire Flicker (soft)"
       - "Fire Flicker (intense)"
       - "Circus Combustus"
       - "Halloween"
       - "Bicolor Chase"
       - "Tricolor Chase"
       - "ICU"
       - "E131"
      brightness: true
      color_temp: true
      rgb: true
      optimistic: true
      qos: 0
      retain: true

Thanks. Now I see why Home Assistant has rejected on_command_type.

When you use schema: json the list of valid configuration variables is different from the standard version of MQTT Light. The JSON version does not support on_command_type.

In previous versions, Home Assistant would ignore invalid options. Starting with 0.87 invalid options are identified and Home Assistant will reject the associated entity. You must remove on_command_type from this entity’s configuration.

I’d like to draw your attention to two other issues in your configuration. You have specified a state_topic and set optimistic: true. Why?

  • If the device reports its state (via state_topic) then there’s normally no need to use optimistic: true. Set it to optimistic: false or delete it (false is the default).
  • If the device does not report its state then its helpful to use optimistic: true.

You have also specified retain: true. This is normally inadvisable because it can cause the device to be activated when it, or the MQTT broker, restarts (or WiFi disconnects/reconnects). I provided a more detailed explanation of the issue in this post. I suggest you set it to retain: false or delete it (false is the default).

Thanks for your detailed answer. The template is not mine, but it is taken from

I’ll send a note about that to the author of the template.

About “optimistic”: I used this option because the on/off button on the light flickered in the past version of hassio. In this new version the problem doesn’t occur (although it doesn’t seem to have a perfect behavior)

1 Like

For future reference, when you encounter problems with something from a GitHub repository, first check if there are any existing Issues it may have. For example, the problem you described, concerning on_command_type, was already reported to the author (two weeks ago):