Closed sarkar-anwar closed 5 years ago
Are you using state changes or events? I stopped some time ago to try to mimic a state device. Some devices still do, but beside on/off it makes no sense for the xiaomi button. Please use the HA events, there you should see them all. This is a simple event automation script I used for testing:
- alias: click_log
id: click_log
initial_state: False
trigger:
platform: event
event_type: click
# optional
event_data:
#entity_id: binary_sensor.ikea_of_sweden_tradfri_remote_control_fe39e28d_1
channel: OnOff
action:
- service: logbook.log
data_template:
name: "click event: "
message: "Entity {{ trigger.event.data.entity_id }}, type {{ trigger.event.data.type }}"
The important part is the
event_type: click
If you don't match on the event data you should see all the created events (single/double/long click, etc) Such remotes are stateless devices that only creates events.
I copy pasted your automation script and changed the entity_id and removed the channel data. It does not work. I don't see anything in the log.
- alias: click_log
id: click_log
initial_state: True
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.binary_sensor_lumi_lumi_sensor_switch_032697bd_1_on_off
action:
- service: logbook.log
data_template:
name: "click event: "
message: "Entity {{ trigger.event.data.entity_id }}, type {{ trigger.event.data.type }}"
Strange, it seems your button missing the Multistateinput (18) cluster, where in older buttons the events came in. Can you click in the HA web interface on the device and check if any of the attributes changes, when you use the button. Xiaomi may have changed the firmware in newer versions.
When I press the button nothing changes. If I soft press the reset button at the back, then iqi and rssi changes.
I am by no means an expert, but when I looked at hubitats implementation here, this switch looks different than the other ones.
I will create an extra DH file for your button. Possible my implementation does not cover it looking at the hubitats page
you may wanna try the newest master. It has now a new device handler for your device. Please give it a try and let me know if it does anything better...
Thanks a lot. It works now. Closing the issue.
Hi, I managed to connect the buttons and it showed up as binary_sensor.binary_sensor_lumi_lumi_sensor_switch_032697bd_1_on_off
Issues I am facing is that single or double press does not work. Only triple presses works but even then it takes somewhere between 2-20 seconds to work. I am testing the button using a simple appdaemon script to listen for events from the buttons.
self.listen_state(self.test_button,"binary_sensor.binary_sensor_lumi_lumi_sensor_switch_032697bd_1_on_off")
I have the logger setup the following way-
zigbee.db here
When button is pressed, I don't see anything related to this entity in the log. Just repetitions of the events below:
When I restart hassio, I see the following.