Xiaomi Cube Automation Template

Struggling with templating, please help!

I have a xiaomi cube running through zigbee2mqtt, and want to change my yeelight led light colour according to which side it’s on. The sensor was automatically generated and has a side: option under state attributes in developer tools. Having a blonde moment and not getting anywhere!

I guess something like this could work, checking the z2m log json

- id: 'cubtest'
  alias: 'cubtest'
  trigger:
    platform: mqtt
    topic: zigbee2mqtt/cubeid #something like 0x
  condition:
    condition: template
    value_template: "{{ 3 == trigger.payload_json.side}}"
  action:
    - service: light.turn_on
      entity_id: light.bedroomlight
      data:
        rgb_color: [255,255,255]
        brightness: 35

but keep in mind that this would activate on any kind of action, whether you shake it, rotate it, flip it, and a second one that resets the action label to “” will trigger it twice in a row. So I’d add as a condition that the action would be either flip_90 or flip_180

not sure what datatype the payload is though, so you might need to get the 3 in quotations if its a string

That worked, many thanks! I was putting the number in quotes hence me pulling my hair out!