Trying to set state of button to off

Using HASS.io and HUSBZB-1 to connect a SmartThings Button.

Unboxed a few buttons and find that the state changes from OFF to ON and stays there when pressed.

I can manually change the state to OFF, but have not figured out how to get a script or automation to return the state to OFF after a delay or action.

Any help would be greatly appreciated. Thanks.

3 Likes

Bump.

Any tips oh how to set the state to off would be greatly appreciated! Thanks.

Changed title, hoping for some help.

I haven’t used one of these devices, but I would think, if things are working correctly, that you shouldn’t have to change the state manually.

BTW, when you say “change the state manually”, exactly what do you mean? If you’re doing it by the States page, then you’re not actually changing the device; you’re just changing the state as recorded in the State Machine.

Given what you say, this must be a Z-Wave device. Is that right? Have you looked in the logs (both home-assistant.log and OZW_Log.txt) to see if there are any clues?

Thanks for the reply.

I misspoke but yes, I was using the stat page to reset the state to OFF in HA. Nothing pops up on the log, and it is a zigbee device so nothing in the OZW log. :frowning:

A bit more detail of what I am seeing. When the button is pressed, the state goes from OFF to On. It will stay there until changed via the States page.

Well, I don’t use Zigbee (only Z-Wave), so I can’t personally help much there. But you said OZW log. That’s the Z-Wave log (i.e., openzwave), right? Is that the same log for zigbee, or is there maybe another log to look at for that?

I only mentioned it because you did. Im not sure if there is a zigbee log.

Sorry I dont have much other info as I am a HomeAssistant noob.

Bump for fresh views. Thanks.

Any tips on zigbee debuging?

Total noob here, but just to check - did you enable debug logging in configuration.yaml when you were checking home-assistant.log?

To focus in on some of the ZHA-related modules:

logger:
  default: info
  logs:
    bellows: debug
    zigpy: debug
    homeassistant.components.zha: debug
    homeassistant.components.binary_sensor.zha: debug

You can change default to warn to reduce chattiness some, and you can turn on debug logging for any other relevant modules you come across as well.

If I understand correctly, you should at a minimum be getting some debug logs from bellows.ezsp if there’s any ZigBee message being received in response to button release - that would be the first place to bisect if a message is being received at all.

1 Like

Thanks for helping me get debugging setup! Looks to be grabbing data now. When I press the button, I beleive this is what I get.

2018-08-30 20:24:06 DEBUG (MainThread) [bellows.uart] Data frame: b'6677b1ed542e14b25c954b65ab55921063940fa312316e82d5c66289fc7e3fa7f2bd7e'
2018-08-30 20:24:06 DEBUG (MainThread) [bellows.uart] Sending: b'87009f7e'
2018-08-30 20:24:06 DEBUG (MainThread) [bellows.ezsp] Application frame 69 (incomingMessageHandler) received
2018-08-30 20:24:06 DEBUG (MainThread) [zigpy.zcl] [0x0828:1:0x0500] ZCL request 0x0100: [1, 0, 0, 0]
2018-08-30 20:24:06 DEBUG (MainThread) [homeassistant.components.binary_sensor.zha] Updated alarm state: 1
2018-08-30 20:24:06 DEBUG (MainThread) [zigpy.zcl] [0x0828:1:0x0500] No handler for cluster command 0

@xspudx Is that for a full press-depress cycle? Or just button release?

Ideally, we want to know what bellows.uart traffic there is specifically relating to button release, as we already know it reacts to button depression. If there is no traffic in response to button release, I’m not sure if it could be supported properly.

Of note, I don’t know whether the device is modeled as a switch or a binary_sensor, so at a minimum you should also enable logging for the proper component type.

1 Like

That was on a press/release “click”. The device shows up as a binary sensor button. “binary_sensor.samjin_button_”

I dont think it responds when it is released that is why I have to manually set the state to off on the state page.

I was hoping there was a way to code something into an automation or script that would set the state back to off without needing input from the device.

Thanks for the help.

If you’re only interested in using it as a single-click button and ignoring fancier features, you can set an automation that immediately sets the button state back when the state changes. This way, you’ll get a “turn on” event every time a click occurs.

You won’t be able to do things like long click, but it’s better than nothing.

Yes, that is exactly what I have been trying to figure out. I dont know how to set the state in a automation or a script back to off.

I dont care about anything other than a click.

I think this another example of a needed “indicator” class. Basically it’s too support devices that just generate or require single events and don’t hold state.

In the mean time yes you could just write an automatic to trigger on the on transactions and then set the state back to off again.

maybe soimething like this?

automation:
  - alias: Switch
    trigger:
      platform: state
      entity_id: switch.xxx
      from: 'off'
      to: 'on'
    action:
      - delay: 
          milliseconds: 1250
      - service: homeassistant.turn_off
        entity_id: switch.xxx
1 Like

Weirdly enough, home assistant.turn_off fails to move this binary sensor to off. Changing the state from the state panel does work.

Is there a way to emulate using the state tab in an automation or script?

That seems to be the only answer. Setting it back to off by hand works great, but i need to automate it.

Thanks for all the replies.

1 Like

There is the API which allows you to update state:
https://developers.home-assistant.io/docs/en/external_api_rest.html#post-api-states-lt-entity-id

Investigating further to see if it’s somehow better supported in automations.