forked from kubaceg/sofar_g3_lsw3_logger_reader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
74 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
/sofar | ||
sofar_g3_lsw3_logger_reader | ||
config.yaml | ||
sofar | ||
sofar-arm | ||
.idea | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Custom Component to run sofar_g3_lsw3_logger_reader | ||
|
||
## Introduction | ||
|
||
`sofar_g3_lsw3_logger_reader` is a program written in go that: | ||
- loops forever, polling the LSW3 data logger and writing the data to a MQTT topic | ||
- reads its `config.yaml` from the current working directory | ||
- writes logging to stderr | ||
- supports MQTT Discovery | ||
|
||
This component runs `sofar_g3_lsw3_logger_reader` with: | ||
- the current working directory set to /config/custom_components/sofar_g3_lsw3_logger_reader | ||
- stdout/err going to files out/err.log (because I haven't succeeded in integrating it with homeassistant logging) | ||
|
||
## Installation | ||
|
||
1. First get `sofar_g3_lsw3_logger_reader` working on your dev machine, so that you have a working `config.yaml` and `sofar` (x86) and `sofar-arm` (arm) binary executables. | ||
2. Copy this directory `custom_components/sofar_g3_lsw3_logger_reader` to homeassistant's `/config/custom_components` | ||
(creating `/config/custom_components/sofar_g3_lsw3_logger_reader`). | ||
You can use the `Samba share` or `Advanced SSH & Web Terminal` add-ons to do this. | ||
3. Copy the working `config.yaml` (from step 1) to the same directory. | ||
4. Copy the `sofar` (x86) or `sofar-arm` (arm) binary executable (from step 1) to `sofar` in this same directory. | ||
5. Enable the custom component by adding a line `sofar_g3_lsw3_logger_reader:` to homeassistant's `/config/configuration.yaml`. | ||
6. Do a full restart of homeassistant: `Developer Tools` > `YAML` > `CHECK CONFIGURATION` then `RESTART` > `Restart Home Assistant` | ||
7. Check the content of `err.log` in this same directory. | ||
8. Add the `Inverter` device to your dashhboard: `Settings` > `Devices & Services` > `Integration` > `MQTT` > `1 device` > `ADD TO DASHBOARD` | ||
|
||
## To Do | ||
|
||
1. Add to HACS | ||
2. Get logging going to homeassistant's log. | ||
3. Add support for "config flow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Integration for Sofar Solar PV inverters with LSW-3 WiFi sticks with SN 23XXXXXXX""" | ||
|
||
import subprocess | ||
import logging | ||
import os | ||
|
||
DOMAIN = "sofar_g3_lsw3_logger_reader" | ||
_LOGGER = logging.getLogger(__name__) | ||
|
||
def setup(hass, config): | ||
hass.states.set("sofar_g3_lsw3_logger_reader.status", __name__) | ||
_LOGGER.warning("setup: Working Dir is %s", os.getcwd()) | ||
_LOGGER.info("setup: Working Dir is %s", os.getcwd()) # main configuration.yaml should enable info, but not yet working | ||
|
||
out = open(f"/config/custom_components/{DOMAIN}/out.log", "w") # empty | ||
err = open(f"/config/custom_components/{DOMAIN}/err.log", "w") # go logging package writes to stderr | ||
proc = subprocess.Popen(f"/config/custom_components/{DOMAIN}/sofar", cwd=f"/config/custom_components/{DOMAIN}", stdout=out, stderr=err) | ||
# the sofar process is left running forever | ||
_LOGGER.warning("setup: end") | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"domain": "sofar_g3_lsw3_logger_reader", | ||
"name": "Sofar LSW3", | ||
"version": "0.1.0", | ||
"integration_type": "device", | ||
"iot_class": "local_polling", | ||
"dependencies": ["mqtt"], | ||
"documentation": "https://github.com/neilbacon/sofar_g3_lsw3_logger_reader" | ||
} |