Hi,
I wanted to get rid of the Aqara Control gateway and so I bought a cc2531 zigbee sniffer.
My doors sensors work fine already.
But I have some problems with the Cube.
First it is not autodetected like the other senors, so I had to implement this:
- sensor:
- platform: "mqtt"
name: Cube state
state_topic: "zigbee2mqtt/0x00XXXXXXXX"
availability_topic: "zigbee2mqtt/bridge/state"
icon: "mdi:gesture-double-tap"
value_template: "{{ value_json.action }}"
json_attributes:
- "battery"
- "voltage"
- "angle"
- "side"
- "from_side"
- "to_side"
- "brightness"
- "angle_x_absolute"
- "angle_y_absolute"
- "angle_z"
- "angle_y"
- "angle_x"
- "unknown_data"
force_update: true
This is an example from here https://github.com/Koenkk/zigbee2mqtt/wiki/Integrating-with-Home-Assistant
Before I had a working automation like this:
- alias: Cube - flip90
initial_state: 'on'
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_XXXXXXX
action_type: flip90
action:
- service: homeassistant.toggle
entity_id: light.flaschen
With the new mqtt sensor I tried this:
- alias: Cube - flip90
initial_state: 'on'
trigger:
platform: state
entity_id: sensor.cube_state
to: 'flip90'
action:
- service: homeassistant.toggle
entity_id: light.flaschen
The problem is that toggling the light will not work, because the state does not change. So if flip90 changes to flip90 again the automation will not do anything.
How can I make this work?
The next thing that does not work is using the rotation as a dimmer function
this one worked before, but I have no clue how to change it to make it work with the mqtt sensor.
- alias: Cube - rotate
initial_state: 'on'
trigger:
- platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_XXXXXXX
action_type: rotate
action:
- service: light.turn_on
data:
entity_id: light.kugellicht
color_name: darkturquoise
- service: light.turn_on
data_template:
entity_id: light.kugellicht
brightness: >-
{% if trigger.event.data.action_value | float > 0 %}
{{ states.light.kugellicht.attributes.brightness | int + 30 }}
{% else %}
{{ states.light.kugellicht.attributes.brightness | int - 30 }}
{% endif %}