8000 Add Atorch S1 support (Closes: #60) by syssi · Pull Request #71 · syssi/esphome-atorch-dl24 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Atorch S1 support (Closes: #60) #71

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

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ jobs:
- name: Write secrets.yaml
shell: bash
run: 'echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password\ndl24_mac_address: FF:FF:FF:FF:FF:FF\ndl24_mac_address0: FF:FF:FF:FF:FF:F0\ndl24_mac_address1: FF:FF:FF:FF:FF:F1\n" > secrets.yaml'
- name: Write tests/secrets.yaml
shell: bash
run: 'echo -e "wifi_ssid: ssid\nwifi_password: password\nmqtt_host: host\nmqtt_username: username\nmqtt_password: password\ndl24_mac_address: FF:FF:FF:FF:FF:FF\ndl24_mac_address0: FF:FF:FF:FF:FF:F0\ndl24_mac_address1: FF:FF:FF:FF:FF:F1\n" > tests/secrets.yaml'
- run: |
esphome -s external_components_source components config esp32-ac-meter-example.yaml
esphome -s external_components_source components config esp32-ac-meter-example-debug.yaml
Expand All @@ -198,6 +201,12 @@ jobs:
esphome -s external_components_source components config esp32-usb-meter-example.yaml
esphome -s external_components_source components config esp32-usb-meter-example-debug.yaml
esphome -s external_components_source components config esp32-usb-meter-example-faker.yaml
esphome -s external_components_source ../components config tests/esp32-atorch-dt3010-faker.yaml
esphome -s external_components_source ../components config tests/esp32-atorch-dt3010.yaml
esphome -s external_components_source ../components config tests/esp32-atorch-j7-c-faker.yaml
esphome -s external_components_source ../components config tests/esp32-atorch-j7-c.yaml
esphome -s external_components_source ../components config tests/esp32-atorch-s1-faker.yaml
esphome -s external_components_source ../components config tests/esp32-atorch-s1.yaml

esphome-compile:
runs-on: ubuntu-latest
Expand Down
45 changes: 45 additions & 0 deletions tests/esp32-atorch-s1-faker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<<: !include esp32-atorch-s1.yaml

atorch_dl24:
- id: atorch0
ble_client_id: ble_client0
check_crc: false
# The meter publishes a status report per second via BLE notification. If you don't like this update interval
# you can use this setting to throttle the sensor updates by skipping some status reports.
throttle: 0s

interval:
- interval: 10s
then:
- lambda: |-
const uint8_t frame[36] = {
0xFF, 0x55, 0x01, 0x01, 0x00, 0x09, 0x06, 0x00, 0x00, 0x28, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xED, 0x00,
0x00, 0x64, 0x01, 0xF4, 0x00, 0x53, 0x00, 0x20, 0x00, 0x0E, 0x0D, 0x08, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x5F
};
id(atorch0).decode(frame, sizeof(frame));

- delay: 2s
- lambda: |-
const uint8_t frame[36] = {
0xFF, 0x55, 0x01, 0x01, 0x00, 0x09, 0x02, 0x00, 0x00, 0x28, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0xED, 0x00,
0x00, 0x64, 0x01, 0xF4, 0x00, 0x4F, 0x00, 0x1E, 0x00, 0x0E, 0x0D, 0x09, 0x3C, 0x00, 0x00, 0x00, 0x00, 0xE9
};
id(atorch0).decode(frame, sizeof(frame));

- delay: 2s
- lambda: |-
const uint8_t frame[36] = {
0xFF, 0x55, 0x01, 0x01, 0x00, 0x09, 0x01, 0x00, 0x00, 0x28, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xED, 0x00,
0x00, 0x64, 0x01, 0xF4, 0x00, 0x59, 0x00, 0x1F, 0x00, 0x0E, 0x0D, 0x0A, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x07
};
id(atorch0).decode(frame, sizeof(frame));

# ff:55:01:01:00:08:fe:00:00:28:00:00:07:00:00:00:ed:00:00:64:01:f4:00:55:00:1f:00:0e:0d:0b:3c:00:00:00:00:1d
# ff:55:01:01:00:09:02:00:00:28:00:00:08:00:00:00:ed:00:00:64:01:f4:00:58:00:20:00:0e:0d:0c:3c:00:00:00:00:3e
# ff:55:01:01:00:09:04:00:00:28:00:00:07:00:00:00:ed:00:00:64:01:f4:00:53:00:20:00:0e:0d:0d:3c:00:00:00:00:dc
# ff:55:01:01:00:09:0c:00:00:28:00:00:08:00:00:00:ed:00:00:64:01:f4:00:5b:00:20:00:0e:0d:0e:3c:00:00:00:00:0c
# ff:55:01:01:00:09:07:00:00:28:00:00:08:00:00:00:ed:00:00:64:01:f4:00:5c:00:20:00:0e:0d:0f:3c:00:00:00:00:31
# ff:55:01:01:00:09:05:00:00:28:00:00:08:00:00:00:ed:00:00:64:01:f4:00:5d:00:20:00:0e:0d:10:3c:00:00:00:00:de
# ff:55:01:01:00:08:fc:00:00:28:00:00:08:00:00:00:ed:00:00:64:01:f4:00:60:00:1f:00:0e:0d:11:3c:00:00:00:00:04
# ff:55:01:01:00:08:e8:00:00:28:00:00:07:00:00:00:ed:00:00:64:01:f4:00:53:00:20:00:0e:0d:12:3c:00:00:00:00:02
# ff:55:01:01:00:08:e3:00:00:27:00:00:07:00:00:00:ed:00:00:64:01:f4:00:51:00:20:00:0e:0d:13:3c:00:00:00:00:79
121 changes: 121 additions & 0 deletions tests/esp32-atorch-s1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
substitutions:
name: atorch-ac-meter
external_components_source: github://syssi/esphome-atorch-dl24@main
dl24_mac_address: !secret dl24_mac_address
project_version: 2.0.0
device_description: "Monitor and control a Atorch meter via bluetooth"

esphome:
name: ${name}
comment: ${device_description}
project:
name: "syssi.esphome-atorch-dl24"
version: ${project_version}

esp32:
board: wemos_d1_mini32
framework:
type: esp-idf

external_components:
- source: ${external_components_source}
refresh: 0s

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

ota:

logger:
level: DEBUG

# If you use Home Assistant please remove this `mqtt` section and uncomment the `api` component!
# The native API has many advantages over MQTT: https://esphome.io/components/api.html#advantages-over-mqtt
mqtt:
broker: !secret mqtt_host
username: !secret mqtt_username
password: !secret mqtt_password
id: mqtt_client

# api:

esp32_ble_tracker:

ble_client:
- mac_address: ${dl24_mac_address}
id: ble_client0

atorch_dl24:
- id: atorch0
ble_client_id: ble_client0
check_crc: false
# The meter publishes a status report per second via BLE notification. If you don't like this update interval
# you can use this setting to throttle the sensor updates by skipping some status reports.
throttle: 0s

binary_sensor:
- platform: atorch_dl24
atorch_dl24_id: atorch0
running:
name: "${name} running"

sensor:
- platform: atorch_dl24
atorch_dl24_id: atorch0
voltage:
name: "${name} voltage"
current:
name: "${name} current"
power:
name: "${name} power"
capacity:
name: "${name} capacity"
energy:
name: "${name} energy"
temperature:
name: "${name} temperature"
dim_backlight:
name: "${name} dim backlight"
frequency:
name: "${name} frequency"
power_factor:
name: "${name} power_factor"
price_per_kwh:
name: "${name} price per kwh"
runtime:
name: "${name} runtime"

text_sensor:
- platform: atorch_dl24
atorch_dl24_id: atorch0
runtime_formatted:
name: "${name} runtime formatted"

# If you use `mqtt` you can control a button if you publish the message "PRESS". The topic depends on
# the name of your ESPHome node and the name of the button entity:
#
# mosquitto_pub -t 'atorch-ac-meter/button/atorch-ac-meter_reset_energy/command' -m 'PRESS'
# mosquitto_pub -t 'atorch-ac-meter/button/atorch-ac-meter_reset_capacity/command' -m 'PRESS'
# mosquitto_pub -t 'atorch-ac-meter/button/atorch-ac-meter_reset_runtime/command' -m 'PRESS'
# mosquitto_pub -t 'atorch-ac-meter/button/atorch-ac-meter_reset_all/command' -m 'PRESS'
# ...
button:
- platform: atorch_dl24
atorch_dl24_id: atorch0
reset_energy:
name: "${name} reset energy"
reset_capacity:
name: "${name} reset capacity"
reset_runtime:
name: "${name} reset runtime"
reset_all:
name: "${name} reset all"
plus:
name: "${name} plus"
minus:
name: "${name} minus"
setup:
name: "${name} setup"
enter:
name: "${name} enter"
0