How to turn off/on bulb when I close phone to the same tag

Hi guys

I would like to create automation in HA to turn off/on bulb when I close my phone to tag.

So, for I am using scene (this scene just do bulb ON) in HA then in iOS I create shortcut where I activate scene from HA, then I create automation which is activated by close to tog.

This is working, but I can only turn ON bulb, in this scenario I would need to create another scene in HA to turn off bulb - to me this is looks like duplicate things.

I would like to use just one tag to turn off and on.

Could you please review my approach ? Maybe it is overkill and I can have this easier?

Instead of activating a scene use the light.toggle action.

Thank you @tom_l

your advise works - now every time I close phone to tag bulb is on or off

Hi @tom_l

Now, I noticed strange thing.
When my automation is enabled in HA, then switch for bulb does not work correct on dashboard.
When I try switch on it switch for 1 sec and go off.
Once I turn off automation switch working fine.

Share your automation yaml correctly formatted for the forum.

Hi @tom_l

This is my automation

alias: lrb1
description: switch bulb 1 on or off
triggers:
  - trigger: state
    entity_id:
      - light.innr_rb_279_t_light
conditions:
  - condition: state
    entity_id: light.innr_rb_279_t_light
    state: "on"
actions:
  - action: light.toggle
    metadata: {}
    data:
      kelvin: 2533
      brightness_pct: 25
    target:
      entity_id: light.innr_rb_279_t_light
mode: single

You are triggering on any change of the light state. You need to trigger on the tag scanned event.

And remove the condition.

Not sure how can I trigger for tag scan in HA.

Right now I have setup automation in iOS which is trigger when I scan tag. Should I scan tag in HA instead of iOS automation?

Does that have a light toggle instead of light turn on action?

Then you would not need the home assistant automation at all.

I can not add this bulb to ios - I can only use it in HA - this bulb can connct to zigbee 3,0 USB which is integrated with HA. So, I think I need HA

You can add any home assistant light to HomeKit.

Thank you - integrated HA wit HomeKit and now automation working good - and switch in HA also

Thank you

1 Like