Please set SONOFF basic

Good day.

please someone would write me * .yaml for SONOFF basic ESPhome.
I need the contact to turn ON when the voltage at the L and N inputs (I don’t need the contact, I just need to monitor the voltage).
Or if Sonoff basic has the option of a sensor for the sensor to report that the basic is energized?
The button would change the state of the contact, but only for x seconds, after the time has elapsed, the contact will ON again.

Honestly,

I do not think anyone will do your work for you but if you try then many will help! As hard as it sounds there is no easy way here. You are expected to put your bit in first. You may have to understand a new (written) language, You may have to find the right hardware for the job you want to do?
Those choices are yours. In many years I have never visited any forum that will do your work if you do not try to solve it for yourself!

having said that what have you done so far? Please ensure that you provide code with the correct formatting!

2 Likes

I’m not sure it’s a Sonoff basic you actually need.
Can you describe the situation this device is going to be in.
Maybe there is a much easier and cheaper solution.

I am sorry

I discovered Homeassistant and Sonoff about 2 months ago. You learn slowly with the language barrier. Well, maybe by winter I will be able to learn everything so that I can control the heating.
I apologize once again and promise not to waste the forrum again.

With God

The sonoff basic has no power metering capabilities ? How are you going to measure the voltage ?

I believe what he wants is a boolean return when the device connected is running or not.
That is also why I believe the Sonoff basic is not the correct tool.

Oh, I have a bunch of sonoff basics for that purpose. Sonoff 4 CH Pro that switch on a contacter / teleruptor in the distribution box, sonoff basic to know if the light is on or off.

I am preparing 4x TH-10 for measuring temperature and humidity in 4 rooms and 5x POW for switching and measuring heating and water heating. The electricity distribution company provides me with a lower price of electricity for some time a day and controls it with an electrical impulse that I just need to monitor.

I have Sonoff basic in ESP and I know for sure that sonoff basic with originall firmware can do what I need - after the voltage returns it turns on to the desired state and that’s enough for me. I just don’t know how to set it up in ESP firmware

That’s the way to do it! Be honest and you will see how it kickstarts some help!
Do have a read here;

I have always found this forum the most helpful if you are trying!

Sorry to anyone I may have offended with my last post.

do you have a bad day today ???

Maybe but no more so than most. Always like to help but never like working for nothing!

so don’t work here if thank you, the smile and the joy of those you help are not enough

You could use a binary_sensor to confirm that the device is connected to Home Assistant:

binary_sensor:

  - platform: status
    name: "${friendly_name} Server Status"

You could then start an automation that if the Sonoff is connected it does something:

automation:
  trigger:
    platform: state
    entity_id: binary_sensor.sonoffname_server_status
    from: "off"
    to: "on"

Or if you want the Sonoff to always turn the relay on when power is applied to the Sonoff (restore_mode)

switch:
  - platform: gpio
    pin: GPIO12
    name: "Device Name"
    restore_mode: "ALWAYS_ON"

my default first attempt

binary_sensor:
- platform: gpio
  pin:
    number: GPIO0
    mode: INPUT_PULLUP
    inverted: True
  name: "HDO tlačítko"
  on_press:
    - switch.toggle: relay
- platform: status
  name: "HDO status"


switch:
- platform: gpio
  name: "HDO spínač"
  pin: GPIO12
  id: relay
  restore_mode: "ALWAYS_ON"

You need to watch your formatting otherwise it will not work.
If you want the LED to act as a status you will want something like the following:

esphome:
  name: "device_name"
  platform: ESP8266
  board: esp8285

wifi:
  ssid: wifi_ssid
  password: wifi_password

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "HDO tlačítko"
    on_press:
      - switch.toggle: relay
  - platform: status
    name: "HDO status"

light:

  - platform: binary
    output: status_led
    id: led

switch:
  - platform: gpio
    name: "HDO spínač"
    pin: GPIO12
    id: relay
    restore_mode: "ALWAYS_ON"
    on_turn_on:
      - light.turn_on:
          id: led
    on_turn_off:
      - light.turn_off:
          id: led

output:
  - platform: gpio
    pin:
      number: GPIO13
      inverted: yes
    id: status_led

You could then have an automation that tells you when the device is connected / has power.

automation:
  trigger:
    - platform: state
      entity_id: binary_sensor.hdo_server_status
      to: "on"
  action:
    - service: notify.notify
      data:
        message: Your device has power

yes - thank you - I have no problem with that

Let me probably have a stupid question. Why can’t I see any entity from the switch?

Have you added it in the Integrations page?

Did you add:

api:
  password: password_you_have_set

Full info

Or you could use MQTT

I personally use the native API.

Thank you it is enough but not for those who do not try!