Trying to set state of button to off

The battery percentage is reported at twice the actual value. That way it can give you half-percent accuracy using integers. So if it’s giving you a value of 177, the actual percentage is 88.5%. I found that in the SmartThings documentation for the unit.

1 Like

Lame, cause I really need half percentage accuracy on my battery status :slight_smile: Looks like we will need a quirk to correct that I guess.

would also like to see your double click and long press code if you can post it

There is a new quirk being added to zha-device-handlers which will add zha_event’s for the button. I think David said it will arrive in 0.90.

https://github.com/dmulcahey/zha-device-handlers/blob/dm/update-new-zha-structure/zhaquirks/samjin/button.py.

Once this is in place, you will be able to use event triggers in your automations to pick up the single, double and long click events!

Once this is in, we can extend the quirk to fix the battery percentage as well.

2 Likes

For the battery percentage, just use a value template:

  - platform: template
    sensors:
      button_battery:
        friendly_name: "Button Battery"
        icon_template: "mdi:battery"
        value_template: "{{ states('sensor.samjin_button_0103374e_1_1') | multiply(0.5) | float(1) }}"
        unit_of_measurement: "%"
1 Like

This works, but its super lame that Samsung decided that a full battery is 200%.

So I was using this set state script quite nicely for a while but one of the recent Home Assistant updates seems to have broken something with this device…

I’m currently on 0.88.1 for reference.

A strange loop started happening where I had to disable the device entirely… If the button was used to turn my light on, it would turn off shortly after on its own, and then turn back on… And so on… On and off indefinitely until I disabled all the scripts and automations… Strange part is I didn’t change anything… And I just have one automation that turns the lamp on if it is off and the other turns it off if it is on… But these automations only trigger when the button is pressed.

Now… It appears the button state changes/cycles on its own which is what is causing this behavior.

Lastly, the REAL MAJOR issue I am having is that I can’t even look at the button state in the Home Assistant Dashboard… If I click on the button to load the current state and history visually, the Dashboard locks up…

Has anyone else had issues with this button?

I had the same issue, didnt bother to investigate because thankfully a quirk has been added to include zha_events for this device.

Here is my new trigger (created using automation editor, ignore wierd formatting). Just change your device_ieee to match your own device:

id: '1536818825531'
  alias: Nursery button - single
  trigger:
  - event_data:
      command: button_single
      device_ieee: 28:6d:97:00:01:00:b8:a9
    event_type: zha_event
    platform: event
  condition: []
  action:
  - data:
      entity_id: light.nursery_lamp
    service: light.toggle

Also available is button_double and button_hold commands.

Awesome, thanks for the example! I saw this was coming but didn’t realize it was out already. This is a great fix!

Ok, finally got a chance to give this a spin… the automation itself works great if I trigger it manually but it doesn’t appear to pick up on the button_single press zha_event… in fact, it doesn’t appear that Home Assistant is picking up any presses as zha_events when I tested the event listener.

I noticed that if I look at the button in the ZHA configuration panel it shows “Quirk applied: false”… is there something I have to do to turn this on? Might there be some configuration I am missing or anything you can think of that I could look at to troubleshoot this?

Oh looks like this have been released yet, I patched the change into the quirks package.

Should be out in 0.90.

Just upgraded to 0.90, and it works on the first button press to turn it on/off (I have it set to toggle), but Home Assistant itself never registers the the light/entity actually toggled (it stays stuck in whatever state it was before the button was pressed even though the state clearly changed).

And if I try any subsequent presses, it doesn’t do anything else… Really strange behavior. Have you not had this problem I assume?

The light I am toggling is another zigbee bulb attached to the same zigbee radio as the SmartThings button.

Weird, so your saying that you capture the zha_event, then you do a light.toggle, and the light physically does toggle, however there state in HA didn’t update?

That’s weird and seems to be a general ha bug. I haven’t actually testing much since updating to 0.90, just flying out so will check it out again on Tuesday.

Correct, though I can’t exactly say I’ve “captured” the zha_event… I know I saw something about a new monitoring tool for zha_events, but I wasn’t sure if that had been implemented yet or where to view the events log for zha.

But after I perform the first light.toggle using the button, the light gets stuck in its new state (though HA never updates with the new state)… it’s a pretty weird issue I am seeing to be honest

Looks like there might have been some sort of bug relating to zha reporting fixed in 0.90.1, not sure if that’s related.

Hey guys,

I’m new to HomeAssistant and having troubles getting my SmartThings Button to work correctly. I’m running hassio 0.91.0b3 on a RaspberryPi and seem to be having the same issues as the original poster.

After connecting the button, the state is initially Off. When I click the button, the state changes to On, but then never resets back to Off. If I manually change the state to Off, the state changes to On again after a few seconds without pressing the button. Any subsequent button presses don’t seem to register.

The full log for connecting the button is below.

Considering <class 'zhaquirks.samjin.button.SamjinButton'>
Fail because input cluster mismatch on at least one endpoint

Does the snippet above indicate that the quirk is not being applied correctly?

Device 0x823e (28:6d:97:00:01:03:38:27) joined the network
[0x823e] Discovering endpoints
Device 0x9093 (28:6d:97:00:01:03:38:27) joined the network
Device 28:6d:97:00:01:03:38:27 changed id (0x823e => 0x9093)
Canceling old initialize call
Failed ZDO request during device initialization: 
[0x9093] Discovering endpoints
[0x9093:zdo] ZDO request 0x0013: [37011, 28:6d:97:00:01:03:38:27, 128]
[0x9093] Discovered endpoints: [1]
[0x9093:1] Discovering endpoint information
[0x9093:1] Discovered endpoint information: <SimpleDescriptor endpoint=1 profile=260 device_type=1026 device_version=0 input_clusters=[0, 1, 3, 32, 1026, 1280] output_clusters=[3, 25]>
[0x9093:1] Manufacturer: Samjin
[0x9093:1] Model: button
Considering <class 'zigpy.quirks.smartthings.SmartthingsMultiPurposeSensor'>
Fail because input cluster mismatch on at least one endpoint
Considering <class 'zigpy.quirks.kof.CeilingFan'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zigpy.quirks.keen.KeenTemperatureHumiditySensor'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zigpy.quirks.ikea.TradfriPlug'>
Fail because endpoint list mismatch: dict_keys([1, 2, 242]) {1}
Considering <class 'zhaquirks.centralite.3130.CentraLite3130'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.centralite.3300S.CentraLite3300S'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.centralite.3305S.CentraLite3305S'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.centralite.3310S.CentraLite3310S'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.centralite.3315S.CentraLite3315S'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.centralite.3320.CentraLite3320'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.centralite.3321S.CentraLite3321S'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.centralite.motion.CentraLiteMotionSensor'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.netvox.z308e3ed.Z308E3ED'>
Fail because input cluster mismatch on at least one endpoint
Considering <class 'zhaquirks.osram.lightifyx4.LightifyX4'>
Fail because endpoint list mismatch: dict_keys([1, 2, 3, 4, 5, 6]) {1}
Considering <class 'zhaquirks.philips.rwl021.PhilipsRWL021'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.samjin.button.SamjinButton'>
Fail because input cluster mismatch on at least one endpoint
Considering <class 'zhaquirks.smartthings.motionv4.SmartThingsMotionV4'>
Fail because model mismatch on at least one endpoint
Considering <class 'zhaquirks.smartthings.multiv4.SmartThingsMultiV4'>
Fail because model mismatch on at least one endpoint
Considering <class 'zhaquirks.smartthings.tag_v4.SmartThingsTagV4'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.visonic.mct340e.MCT340E'>
Fail because model mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.aqara.cube_aqgl01.CubeAQGL01'>
Fail because endpoint list mismatch: dict_keys([1, 2, 3]) {1}
Considering <class 'zhaquirks.xiaomi.aqara.magnet_aq2.MagnetAQ2'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.aqara.motion_aq2.MotionAQ2'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.aqara.remote_b286acn01.RemoteB286ACN01'>
Fail because endpoint list mismatch: dict_keys([1, 2, 3]) {1}
Considering <class 'zhaquirks.xiaomi.aqara.sensor_switch_aq3.SwitchAQ3'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.aqara.switch_aq2.SwitchAQ2'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.aqara.vibration_aq1.VibrationAQ1'>
Fail because endpoint list mismatch: dict_keys([1, 2]) {1}
Considering <class 'zhaquirks.xiaomi.aqara.weather.Weather'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.aqara.wleak_aq1.LeakAQ1'>
Fail because model mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.mija.motion.Motion'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.mija.sensor_ht.Weather'>
Fail because endpoint list mismatch: dict_keys([1, 2, 3]) {1}
Considering <class 'zhaquirks.xiaomi.mija.sensor_magnet.Magnet'>
Fail because device_type mismatch on at least one endpoint
Considering <class 'zhaquirks.xiaomi.mija.sensor_switch.MijaButton'>
Fail because device_type mismatch on at least one endpoint
Samjin button: started configuration
node descriptor: [<Status.SUCCESS: 0>, 37011, <NodeDescriptor byte1=2 byte2=64 mac_capability_flags=128 manufacturer_code=4673 maximum_buffer_size=82 maximum_incoming_transfer_size=82 server_mask=11264 maximum_outgoing_transfer_size=82 descriptor_capability_field=0>]
Samjin button: channel: zdo-Samjin button_ZDO async_configure stage succeeded
0x9093:1:0x0000: finished channel configuration
Samjin button: channel: basic-0x9093:1:0x0000 async_configure stage succeeded
0x9093:1:0x0500: started IASZoneChannel configuration
0x9093:1:0x0001: bound  'power' cluster: Status.SUCCESS
0x9093:1:0x0402: bound  'temperature' cluster: Status.SUCCESS
0x9093:1:0x0500: bound  'ias_zone' cluster: Status.SUCCESS
0x9093:1:0x0001: reporting 'battery_voltage' attr on 'power' cluster: 30/900/1: Result: '[[<ConfigureReportingResponseRecord status=0 direction=0 attrid=0>]]'
0x9093:1:0x0402: reporting 'measured_value' attr on 'temperature' cluster: 30/900/50: Result: '[[<ConfigureReportingResponseRecord status=0 direction=0 attrid=0>]]'
0x9093:1:0x0500: wrote cie_addr: 00:0d:6f:00:0b:29:a0:f5 to 'ias_zone' cluster: [<WriteAttributesStatusRecord status=Status.SUCCESS attrid=0>]
0x9093:1:0x0500: finished IASZoneChannel configuration
0x9093:1:0x0402: finished channel configuration
Samjin button: channel: attribute-0x9093:1:0x0402 async_configure stage succeeded
Samjin button: channel: ias_zone-0x9093:1:0x0500 async_configure stage succeeded
0x9093:1:0x0001: reporting 'battery_percentage_remaining' attr on 'power' cluster: 30/900/1: Result: '[[<ConfigureReportingResponseRecord status=0 direction=0 attrid=0>]]'
0x9093:1:0x0001: finished channel configuration
Samjin button: channel: power-0x9093:1:0x0001 async_configure stage succeeded
Samjin button: completed configuration
Samjin button: stored in registry: ZhaDeviceEntry(name='Samjin button', ieee='28:6d:97:00:01:03:38:27', power_source=0, manufacturer_code=4673, last_seen=1554007869.3819785)
Samjin button: started initialization
entry loaded from storage: ZhaDeviceEntry(name='Samjin button', ieee='28:6d:97:00:01:03:38:27', power_source=0, manufacturer_code=4673, last_seen=1554007869.3819785)
Samjin button: channel: zdo-Samjin button_ZDO async_initialize stage succeeded
Samjin button: channel: basic-0x9093:1:0x0000 async_initialize stage succeeded
Samjin button: channel: attribute-0x9093:1:0x0402 async_initialize stage succeeded
Samjin button: channel: ias_zone-0x9093:1:0x0500 async_initialize stage succeeded
Samjin button: channel: power-0x9093:1:0x0001 async_initialize stage succeeded
Samjin button: power source: Battery or Unknown
Samjin button: completed initialization
[0x9093:zdo] ZDO request 0x0036: [180, <Bool.true: 1>]
Data remains after deserializing ZCL frame
[0x9093:1:0x0500] ZCL request 0x0101: []
Enroll requested
[0x9093:1:0x0500] No handler for cluster command 1

Look in the zha control panel for this device and it will tell you if the quirk is applied.

image.

In terms of the binary_sensor associated with the device, yeah that doesn’t work, just ignore it. Instead you should capture the zha_event from the device which has been available since 0.90 I believe.

Here is an automation I have for toggling my nursery light based on a single button press:

- id: '1536818825531'
  alias: Nursery button - single
  trigger:
  - event_data:
      command: button_single
      device_ieee: 28:6d:97:00:01:00:b8:a9
    event_type: zha_event
    platform: event
  condition: []
  action:
  - data:
      entity_id: light.nursery_lamp
    service: light.toggle

There are 3 events you can capture right now:

CLICK_TYPES = {
    SINGLE: 'single',
    DOUBLE: 'double',
    HOLD: 'hold'
}

Thanks for providing the script. I tried your automation with one of my lights, and pressing the button does not toggle the light (although triggering the automation manually does work).

Next, I downgraded to Home Assistant 0.90.2, since the “Quirk applied” property doesn’t seem to appear in the latest release candidate. In the image below, it shows that quirks are not applied. My quirk path is also completely different.

I’m sure I’m missing something obvious… How did you load the zhaquirks?

Thanks again for your help!

I think you are running into the same problem I was, in that there are multiple types of Samsung button. David has added the second button into the zha-device-handlers, but maybe it hasn’t integrated into HomeAssistant yet.

https://github.com/dmulcahey/zha-device-handlers/pull/55

In case anyone’s interested, I wrote an AppDaemon app that handles the tap/hold/double events on these buttons and allows you to pick an action for each one: toggle a light, change the brightness of a light, or cycle a light through a list of colors. Check it out here:

(Sorry to cross-post this in multiple threads, but I know when I was originally searching for info on getting this button working natively, there were several discussions out there that hadn’t been resolved at the time and I want to make sure anyone looking for the info finds it.)