Help configuring Ewelink Automation "again"

This is my fist try at HA (Home Assistant). I tried OpenHab a few years ago and gave up but I feel a little better about HA. I have some Linux scripting background, tinkered with adriano among other things.

I have Samba working to access my Raspberry Pi 3 and Visual Studio configured for HA.

I have a Sonoff basic that I have configured in HA through the EWeLink interface and is working from the console. And I have connected my phone through my router to HA and can see when I come and go on the console. I would like to create an automation that turns on the lights and stereo when I drive into the garage.

I’ve been doing lots of reading and searching. I’m confused if I can use the easy GUI menus in Scenes and Automations or if I need to create scripts in the configurations and scenes YAML files. Or a hybread of both?

I was watching:
Location-based automations / device tracking in Home Assistant (2021 Guide)

And reading:
Help configuring Ewelink Automation

I started using the GUI method laid out in the video but I’m not sure if it will work/translate with the restrictions on the EWeLink interface. Maybe I need to switch to MQTT?

If I start trying to script I’ll need to do a good long read through the HA Script Syntax tutorial and maybe try to adapt the scripts written by Tiprin_Lujan form the above link.

Anyone have any advice on how I may move forward from here?

Thanks
Marc

I have a few Sonoff devices and they are all connected to my HA instance using this integration in HACS:
AlexxIT/SonoffLAN: Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant (github.com)
One of the advantages is that the reaction time is very quick.

I’d recommend using an automation and setting it up via the GUI. This should be rather straightforward in terms of trigger (i.e. the state of your device_tracker changes from not_home to home) and action (i.e. you call the service switch.turn_on for your Sonoff entity).
Depending on how quickly your router and HA communicate about the status change, though, you might be half way to the fridge before the light and stereo turn on.

And a more general note:
Despite the fact that I have a few scenes (left over) I’d recommend using scripts to ‘set up scenes’ - it’s equally as simple/complicated for the basics, but gives you more flexibility for conditions, etc.
Another pain with scenes comes up when you try to edit them; whenever you open a scene for editing, HA actually turns that scene on, i.e. when I had set up ‘not at home’ using a scene instead of a script, it turned all smart power switches off and armed the alarm - experiencing the fallout from this gets boring rather quickly :frowning:

Thanks Chairstacker,
I got it running pretty quickly yesterday from following the video and trying to incorporate that with restrictions stated in the eWeLink pages.

I didn’t use the AlexxIT/SonoffLAN files. I had tried to install HACS earlier and had some trouble so I bailed on it for now. But I sense believe I found a newer tutorial.

Instead I found an eWeLink page that is made for HA. Maybe the AlexxIT files would be better and be free of any surveillance incorporated into eWeLinks software.

Here is the eWeLink page I followed:
How to Add Your SONOFF Devices On Home Assistant

eWeLinks says you have to run it in a scene as an entity. So I did that and linked the scene into an automation and it works. I did have to make a slight tweak in the scene yaml and switch state from “off” to “on”.

Today I was trying to get it to turn off when I leave the house. I tried a few different ways in the UI and tweaking in the YAML files but never got it to work.

I spent a good deal of time carefully watching a video on HA yaml syntax and reading up on that and some other configuration stuff. I’m still thinking that I should switch to another approach, probably the AlexxIT repo that you used would be a good go.

I don’t know how how to insert code here but I’ll give it a try.
Here’s my scenes.yaml

- id: '1634241223052'
  name: Garage Stereo
  entities:
    switch.1000268f7f:
      restored: false
      supported_features: 0
      friendly_name: Garage
      state: 'on'
  icon: mdi:music

My Automations.yaml

 id: '1634255645884'
  alias: Garage
  description: ''
  trigger:
  - platform: state
    entity_id: person.marc
    to: home
  condition: []
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.garage_stereo
  mode: single

My configuration.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# eWeLink to Solve Service Not Found added 10-14-2021
switch:
  - platform: template
    switches:
      ewelink_virtual_switch:
        turn_on:
          service: switch.turn_on
        turn_off:
          service: switch.turn_off

cover:
  - platform: template
    covers:
      ewelink_virtual_cover:
        open_cover:
          service: cover.open_cover
        close_cover:
          service: cover.close_cover
        stop_cover:
          service: cover.stop_cover
        set_cover_position:
          service: cover.set_cover_position

fan:
  - platform: template
    fans:
      ewelink_virtual_fan:
        value_template: "{{ states('input_boolean.state') }}"
        turn_on:
          service: fan.turn_on
        turn_off:
          service: fan.turn_off
        set_preset_mode:
          service: fan.set_preset_mode