Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Athom Relay 4CH Esphome #31

Closed
titou4307 opened this issue Oct 17, 2024 · 3 comments
Closed

Athom Relay 4CH Esphome #31

titou4307 opened this issue Oct 17, 2024 · 3 comments

Comments

@titou4307
Copy link

Hello

I don't know if the last version of Esphome break all my conf of this Athom Relay 4CH but this relay seems boot and after each action on switch it reboot, disappear from Home Assistant, ..... impossible to reconnect then reconnection is OK

I have use and adapt the YAML of the product link.....Very hard

Does it possible to have just a YAML for to pilot button, switches ???

substitutions:
  name: "athom-4-relais"
  friendly_name: "Athom 4 Relais"
  room: ""
  device_description: "athom esp32 4ch relay board"
  project_name: "Athom Technology.ESP32 4CH Relay Board"
  project_version: "v2.0.3"
  update_interval: 60s
  # Define a domain for this device to use. i.e. iot.home.lan (so device will appear as athom-smart-plug-v2.iot.home.lan in DNS/DHCP logs)
  dns_domain: ""
  # Set timezone of the smart plug. Useful if the plug is in a location different to the HA server. Can be entered in unix Country/Area format (i.e. "Australia/Sydney")
  timezone: "Europe/Paris"
  # Set the duration between the sntp service polling ntp.org servers for an update
  sntp_update_interval: 6h
  # Network time servers for your region, enter from lowest to highest priority. To use local servers update as per zones or countries at: https://www.ntppool.org/zone/@
  sntp_server_1: "0.pool.ntp.org"
  sntp_server_2: "1.pool.ntp.org"
  sntp_server_3: "2.pool.ntp.org"  
  # Enables faster network connections, with last connected SSID being connected to and no full scan for SSID being undertaken
  wifi_fast_connect: "false"
  # Define logging level: NONE, ERROR, WARN, INFO, DEBUG (Default), VERBOSE, VERY_VERBOSE
  log_level: "DEBUG"
  # Enable or disable the use of IPv6 networking on the device
  ipv6_enable: "false"
  relay1_restore_mode: RESTORE_DEFAULT_OFF
  relay2_restore_mode: RESTORE_DEFAULT_OFF
  relay3_restore_mode: RESTORE_DEFAULT_OFF
  relay4_restore_mode: RESTORE_DEFAULT_OFF

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"
  comment: "${device_description}"
  area: "${room}"
  #name_add_mac_suffix: true
  min_version: 2024.6.0
  project:
    name: "${project_name}"
    version: "${project_version}"
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32dev
  flash_size: 4MB
  framework:
    type: esp-idf
    version: recommended

preferences:
  flash_write_interval: 5min

# Enable logging
logger:
  baud_rate: 115200
  level: ${log_level}

mdns:
  disabled: false

web_server:
  port: 80

# Enable Home Assistant API
api:
  encryption:
    key: "HIDETHISKEYFORGITHUB="

ota:
  - platform: esphome
    password: "HIDETHISKEYFORGITHUB"

network:
  enable_ipv6: ${ipv6_enable}

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.1.38
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.1.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0
    
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Athom-4-Relais Fallback Hotspot"
    password: "HIDETHISKEYFORGITHUB"

captive_portal:

improv_serial:

esp32_improv:
  authorizer: none

#dashboard_import:
#  package_import_url: github://athom-tech/esp32-configs/athom-4ch-relay-board.yaml

# esp32_ble_tracker:
#   scan_parameters:
#     interval: 1100ms
#     window: 1100ms
#     active: true

# bluetooth_proxy:
#   active: true

remote_receiver:
  pin: GPIO17
  dump: rc_switch

binary_sensor:
  - platform: status
    name: "Status"
    entity_category: "diagnostic"

  - platform: gpio
    pin:
      number: GPIO36
      mode:
        input: true
      inverted: true
    name: "Power Button1"
    disabled_by_default: true
    on_multi_click:
      - timing:
        - ON for at most 1s
        - OFF for at least 0.2s
        then:
          - switch.toggle: relay1
      - timing:
        - ON for at least 4s
        then:
          - button.press: Reset
  - platform: gpio
    pin:
      number: GPIO39
      mode:
        input: true
      inverted: true
    name: "Power Button2"
    disabled_by_default: true
    on_multi_click:
      - timing:
        - ON for at most 1s
        - OFF for at least 0.2s
        then:
          - switch.toggle: relay2
      - timing:
        - ON for at least 4s
        then:
          - button.press: Reset
  - platform: gpio
    pin:
      number: GPIO34
      mode:
        input: true
      inverted: true
    name: "Power Button3"
    disabled_by_default: true
    on_multi_click:
      - timing:
        - ON for at most 1s
        - OFF for at least 0.2s
        then:
          - switch.toggle: relay3
      - timing:
        - ON for at least 4s
        then:
          - button.press: Reset
  - platform: gpio
    pin:
      number: GPIO35
      mode:
        input: true
      inverted: true
    name: "Power Button4"
    disabled_by_default: true
    on_multi_click:
      - timing:
        - ON for at most 1s
        - OFF for at least 0.2s
        then:
          - switch.toggle: relay4
      - timing:
        - ON for at least 4s
        then:
          - button.press: Reset

sensor:
  - platform: uptime
    name: "Uptime Sensor"
    id: uptime_sensor
    type:
      timestamp
    entity_category: "diagnostic"

  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: "${update_interval}"
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"
    device_class: ""

button:
  - platform: restart
    name: "Restart"
    entity_category: "config"

  - platform: factory_reset
    name: "Factory Reset"
    id: Reset
    entity_category: "config"

  - platform: safe_mode
    name: "Safe Mode"
    internal: false
    entity_category: "config"

switch:
  # Relay
  - platform: gpio
    name: "Relay1"
    pin: GPIO27
    id: relay1
    restore_mode: ${relay1_restore_mode}
    on_turn_on:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_1/turn_on
    on_turn_off:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_1/turn_off

  - platform: gpio
    name: "Relay2"
    pin: GPIO14
    id: relay2
    restore_mode: ${relay2_restore_mode}
    on_turn_on:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_2/turn_on
    on_turn_off:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_2/turn_off

  - platform: gpio
    name: "Relay3"
    pin: GPIO12
    id: relay3
    restore_mode: ${relay3_restore_mode}
    on_turn_on:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_3/turn_on
    on_turn_off:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_3/turn_off

  - platform: gpio
    name: "Relay4"
    pin: GPIO13
    id: relay4
    restore_mode: ${relay4_restore_mode}
    on_turn_on:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_4/turn_on
    on_turn_off:
      then:
        - http_request.post:
            id: my_http_request_1
            url: http://192.168.1.125/light/prise_4/turn_off

http_request:
  useragent: esphome/device
  timeout: 10s
  id: my_http_request_1
  verify_ssl: false

light:
  - platform: status_led
    name: "Status LED"
    disabled_by_default: true
    pin: GPIO15

text_sensor:
  - platform: wifi_info
    ip_address:
      name: "IP Address"
      entity_category: "diagnostic"
    ssid:
      name: "Connected SSID"
      entity_category: "diagnostic"
    mac_address:
      name: "Mac Address"
      entity_category: "diagnostic"

  #  Creates a sensor showing when the device was last restarted
  - platform: template
    name: 'Last Restart'
    id: device_last_restart
    icon: mdi:clock
    entity_category: "diagnostic"
#    device_class: timestamp

time:
  - platform: sntp
    id: sntp_time
  # Define the timezone of the device
    timezone: "${timezone}"
  # Change sync interval from default 5min to 6 hours (or as set in substitutions)
    update_interval: ${sntp_update_interval}
  # Set specific sntp servers to use
    servers:
      - "${sntp_server_1}"
      - "${sntp_server_2}"
      - "${sntp_server_3}"
  # Publish the time the device was last restarted
    on_time_sync:
      then:
        # Update last restart time, but only once.
        - if:
            condition:
              lambda: 'return id(device_last_restart).state == "";'
            then:
              - text_sensor.template.publish:
                  id: device_last_restart
                  state: !lambda 'return id(sntp_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'

This hardware is very hard to understand...
I have change my Sonoff 4CH Pro R3 (not possible to update in OTA) for this hardware (with Esp32....) but I am desappointed....

I would like to uncomment all the data who are not necessary ....

Thanks for your helps

@tarontop
Copy link
Collaborator

Please try our original complete configuration first, instead of adding some of your custom configuration

@titou4307
Copy link
Author

Hi
The problem is if it reboot, it download the config on your github and reappears like a new device, it don't save the wifi and SSID...

github://athom-tech/athom-configs/athom-relay-board-x4.yaml
Does it possible to have a light config with only the relay and sensors of your product (not hours, no wifi... ??

@tarontop
Copy link
Collaborator

Delete it will not download from our GitHub

dashboard_import:
  package_import_url: github://athom-tech/esp32-configs/athom-4ch-relay-board.yaml

@tarontop tarontop closed this as completed Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants