Lights turn OFF but not ON

I’m using HASS with SmartThings and I’ve been using voice control for a while so I’m not sure when control from HASS stopped working, but it definitely worked before.

I can turn OFF lights via HASS but not ON ( the ON value is not being passed )

Here’s code for one of my lights

- platform: mqtt
  name: "Office Light"
  state_topic: "smartthings/Office Light/switch"
  command_topic: "smartthings/Office Light/switch"
  brightness_state_topic: "smartthings/Office Light/level"
  brightness_command_topic: "smartthings/Office Light/level"
  payload_on: "on"
  payload_off: "off"
  optimistic: false
  retain: true

SmartThings logs show the following.

When I turn OFF the light

126f9fd4-9a7a-49d5-a6c2-ad89f57d5371  8:31:17 PM: debug Received device event from bridge: [name:Office Light, value:off, type:switch]
ac4c8bbb-78d5-43d1-aeb9-653bff9f9d21  8:31:17 PM: debug Parsing 'index:08, mac:18A90528CF5A, headers:UE9TVCAvIEhUVFAvMS4xDQpob3N0OiAxMC4wLjAuOTM6Mzk1MDANCmFjY2VwdDogYXBwbGljYXRpb24vanNvbg0KY29udGVudC10eXBlOiBhcHBsaWNhdGlvbi9qc29uDQpjb250ZW50LWxlbmd0aDogNTMNCkNvbm5lY3Rpb246IGNsb3Nl, body:eyJuYW1lIjoiT2ZmaWNlIExpZ2h0IiwidHlwZSI6InN3aXRjaCIsInZhbHVlIjoib2ZmIn0='

When I turn ON the light

126f9fd4-9a7a-49d5-a6c2-ad89f57d5371  8:31:49 PM: error java.lang.NumberFormatException: For input string: "" @ line 527
126f9fd4-9a7a-49d5-a6c2-ad89f57d5371  8:31:49 PM: debug Received device event from bridge: [name:Office Light, value:, type:level]
ac4c8bbb-78d5-43d1-aeb9-653bff9f9d21  8:31:49 PM: debug Parsing 'index:03, mac:18A90528CF5A, headers:UE9TVCAvIEhUVFAvMS4xDQpob3N0OiAxMC4wLjAuOTM6Mzk1MDANCmFjY2VwdDogYXBwbGljYXRpb24vanNvbg0KY29udGVudC10eXBlOiBhcHBsaWNhdGlvbi9qc29uDQpjb250ZW50LWxlbmd0aDogNDkNCkNvbm5lY3Rpb246IGNsb3Nl, body:eyJuYW1lIjoiT2ZmaWNlIExpZ2h0IiwidHlwZSI6ImxldmVsIiwidmFsdWUiOiIifQ=='

HASS shows - OFF

17-01-19 20:39:41 homeassistant.core: Bus:Handling <Event call_service[L]: service_call_id=1977716816-26, service_data=entity_id=light.office_light, service=turn_off, domain=homeassistant>
17-01-19 20:39:41 homeassistant.core: Bus:Handling <Event call_service[L]: service_call_id=1977716816-27, service_data=entity_id=['light.office_light'], service=turn_off, domain=light>
17-01-19 20:39:41 homeassistant.core: Bus:Handling <Event call_service[L]: service_call_id=1977716816-28, service_data=retain=True, payload=off, qos=0, topic=smartthings/Office Light/switch, service=publish, domain=mqtt>
17-01-19 20:39:41 homeassistant.components.mqtt: Received message on smartthings/Office Light/switch: off
17-01-19 20:39:41 homeassistant.core: Bus:Handling <Event mqtt_message_received[L]: payload=off, qos=0, topic=smartthings/Office Light/switch>

HASS shows - On

17-01-19 20:39:46 homeassistant.core: Bus:Handling <Event call_service[L]: service_call_id=1977716816-29, service_data=entity_id=light.office_light, service=turn_on, domain=homeassistant>
17-01-19 20:39:46 homeassistant.core: Bus:Handling <Event call_service[L]: service_call_id=1977716816-30, service_data=entity_id=['light.office_light'], service=turn_on, domain=light>
17-01-19 20:39:46 homeassistant.core: Bus:Handling <Event call_service[L]: service_call_id=1977716816-31, service_data=retain=True, payload=on, qos=0, topic=smartthings/Office Light/switch, service=publish, domain=mqtt>
17-01-19 20:39:47 homeassistant.components.mqtt: Received message on smartthings/Office Light/switch: on
17-01-19 20:39:47 homeassistant.core: Bus:Handling <Event mqtt_message_received[L]: payload=on, qos=0, topic=smartthings/Office Light/switch>

Any ideas?

thanks

Sorry if I’m not any help because I’ve never used MQTT but I noticed the “on” command that smart things received looks like it is in the “level” state topic and not the “switch” state topic. Is it possible a brightness value needs to be sent to turn the light on?

I noticed that as well, but I don’t think that’s something I can control since I’m having issues using the ON/OFF toggle on the main HASS page.

I found that I can get it to work if I first set the brightness. (by clicking on the name and not the toggle)

Once the brightness is set it works fine so it appears that the MQTT retain information about brightness needs to exist.

I have no idea how to do this, but would it work if the code was updated to default to Brightness 100% if there is no retain info?

The brightness slider while the light is off was just added but I think it was implimented poorly. Home assistant doesn’t keep the brightness information after a light is off. It has been discussed on git by the devs but they don’t like the idea of something that doesn’t actually have brightness (light that is off) to have a brightness in HA. Seems like adding the slider to be used while the light is off might have introduced a bug.

After you move the slider to something other than all the way to the left, can you turn the light off and back on with the toggle switch or do you have to use the slider again before you can turn the light on?

While the light is off, does moving the slider to the right turn the light on or just set the brightness for when the light is eventually turned on?

The brightness slider comes up only after I click ON.
When it did, I moved the slider and click OFF and then ON.

I cleared the MQTT retain info to try to repeat the steps but now it’s not working.

I’ll keep messing with it to see if I can figure out the sequence that made it work.

It definitely seems to be related to not having a level set but I’m still trying to figure out the sequence that got it working the first time.

For now I can set the level via SmartThings and it works every time.

Setting the level via SmartThings worked for all but one device.

The only device that doesn’t work is an Osram Flex strip. I also have a garden spot and their configs appear to be the same. The garden spot works so I’m not sure what’s going on.

This used to work, but as I mentioned in my initial post, I’ve been using voice commands for a while so I don’t know when it stopped working.

Any ideas?

thanks