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

device is automatic powersycling and logging like crazy #48

Open
stefanschaedeli opened this issue Mar 22, 2024 · 2 comments
Open

device is automatic powersycling and logging like crazy #48

stefanschaedeli opened this issue Mar 22, 2024 · 2 comments

Comments

@stefanschaedeli
Copy link

logs_ug-technik-pm-truenas_logs.txt
logs_ug-technik-pm-truenas_run.txt

and my yaml:

`

Enable Home Assistant API

api:
encryption:
key: "XXX="

ota:
password: "XXX"

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 10.15.15.212
gateway: 10.15.15.1
subnet: 255.255.255.0

substitutions:
name: "athom-smart-plug"
friendly_name: "Smart Plug"
room: ""
device_description: "athom smart plug"
project_name: "Athom Technology.Smart Plug"
project_version: "1.0"
relay_restore_mode: RESTORE_DEFAULT_OFF
sensor_update_interval: 10s

esphome:
name: "${name}"
friendly_name: "${friendly_name}"
name_add_mac_suffix: true
project:
name: "${project_name}"
version: "${project_version}"

esp8266:
board: esp8285
restore_from_flash: true

preferences:
flash_write_interval: 1min

logger:

web_server:
port: 80

dashboard_import:
package_import_url: github://athom-tech/athom-configs/athom-smart-plug.yaml

binary_sensor:

  • platform: status
    name: "Status"
    entity_category: diagnostic

  • platform: gpio
    pin:
    number: 3
    mode: INPUT_PULLUP
    inverted: true
    name: "Power Button"
    disabled_by_default: true
    on_multi_click:

    • timing:
      • ON for at most 1s
      • OFF for at least 0.2s
        then:
      • switch.toggle: relay
    • timing:
      • ON for at least 4s
        then:
      • button.press: Reset

sensor:

  • platform: uptime
    name: "Uptime Sensor"
    id: uptime_sensor
    entity_category: diagnostic
    internal: True

  • platform: wifi_signal
    name: "WiFi Signal"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: diagnostic
    internal: true

Reports the WiFi signal strength in %

  • platform: copy
    source_id: wifi_signal_db
    name: "WiFi Strength"
    filters:

    • lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
      unit_of_measurement: "%"
      entity_category: diagnostic
  • platform: hlw8012
    sel_pin:
    number: GPIO12
    inverted: True
    cf_pin: GPIO4
    cf1_pin: GPIO5
    voltage_divider: 780
    current:
    name: "Current"
    filters:
    - calibrate_linear:
    - 0.0000 -> 0.0110 # Relay off no load
    - 0.0097 -> 0.0260 # Relay on no load
    - 0.9270 -> 0.7570
    - 2.0133 -> 1.6330
    - 2.9307 -> 2.3750
    - 5.4848 -> 4.4210
    - 8.4308 -> 6.8330
    - 9.9171 -> 7.9830
    # Normalize for plug load
    - lambda: if (x < 0.0260) return 0; else return (x - 0.0260);
    voltage:
    name: "Voltage"

    power:
    name: "Power"
    id: socket_my_power
    unit_of_measurement: W
    filters:
    - calibrate_linear:
    - 0.0000 -> 0.5900 # Relay off no load
    - 0.0000 -> 1.5600 # Relay on no load
    - 198.5129 -> 87.8300
    - 434.2469 -> 189.5000
    - 628.6241 -> 273.9000
    - 1067.0067 -> 460.1000
    - 1619.8098 -> 699.2000
    - 2043.0282 -> 885.0000
    # Normalize for plug load
    - lambda: if (x < 1.5600) return 0; else return (x - 1.5600);
    change_mode_every: 1
    update_interval: 5s

  • platform: total_daily_energy
    name: "Total Energy"
    power_id: socket_my_power
    unit_of_measurement: kWh
    accuracy_decimals: 3
    restore: true
    filters:

    • multiply: 0.001

button:

  • platform: factory_reset
    name: "Reset"
    id: Reset
    entity_category: config

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

switch:

  • platform: gpio
    name: "Plug"
    pin: GPIO14
    id: relay
    restore_mode: ${relay_restore_mode}
    on_turn_on:

    • light.turn_on: blue_led

    on_turn_off:

    • light.turn_off: blue_led

light:

  • platform: status_led
    name: "Status LED"
    id: blue_led
    disabled_by_default: true
    pin:
    inverted: true
    number: GPIO13

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: 'Device Last Restart'
    id: device_last_restart
    icon: mdi:clock
    entity_category: diagnostic

device_class: timestamp

Creates a sensor of the uptime of the device, in formatted days, hours, minutes and seconds

  • platform: template
    name: "Device Uptime"
    entity_category: diagnostic
    lambda: |-
    int seconds = (id(uptime_sensor).state);
    int days = seconds / (24 * 3600);
    seconds = seconds % (24 * 3600);
    int hours = seconds / 3600;
    seconds = seconds % 3600;
    int minutes = seconds / 60;
    seconds = seconds % 60;
    if ( days > 3650 ) {
    return { "Starting up" };
    } else if ( days ) {
    return { (String(days) +"d " + String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
    } else if ( hours ) {
    return { (String(hours) +"h " + String(minutes) +"m "+ String(seconds) +"s").c_str() };
    } else if ( minutes ) {
    return { (String(minutes) +"m "+ String(seconds) +"s").c_str() };
    } else {
    return { (String(seconds) +"s").c_str() };
    }
    icon: mdi:clock-start

time:

  • platform: sntp
    id: sntp_time

Change sync interval from default 5min to 6 hours

update_interval: 360min    

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");'

`

@tarontop
Copy link
Collaborator

It looks like the button is shaking. Try increasing the time here.

- OFF for at least 0.2s

@stefanschaedeli
Copy link
Author

same behaviour unfortunately:

Uploading Bildschirmaufnahme 2024-05-02 um 15.29.09.mov…

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