Add files via upload

initial commit
This commit is contained in:
habuild 2022-03-16 13:19:15 +11:00 committed by GitHub
parent 86e9d577e6
commit 3e08e65720
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 1600 additions and 0 deletions

201
LICENSE Normal file
View file

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

131
README.md Normal file
View file

@ -0,0 +1,131 @@
[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield]
# Reposistory add-on by Habuild
Add-on documentation: <https://developers.home-assistant.io/docs/add-ons>
[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fhabuild%2Fhassio_addons)
## Add-ons
This repository contains the following add-ons
### [SBFspot_HA](./sbfspot)
![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fhassio_addons%2Fmaster%2Fsbfspot%2Fconfig.json)
![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fhassio_addons%2Fmaster%2Fsbfspot%2Fconfig.json)
_Example add-on to use as a blueprint for new add-ons._
<!--
Notes to developers after forking or using the github template feature:
- While developing comment out the 'image' key from 'example/config.yaml' to make the supervisor build the addon
- Remember to put this back when pushing up your changes.
- When you merge to the 'main' branch of your repository a new build will be triggered.
- Make sure you adjust the 'version' key in 'example/config.yaml' when you do that.
- Make sure you update 'example/CHANGELOG.md' when you do that.
- The first time this runs you might need to adjust the image configuration on github container registry to make it public
- Adjust the 'image' key in 'example/config.yaml' so it points to your username instead of 'home-assistant'.
- This is where the build images will be published to.
- Rename the example directory.
- The 'slug' key in 'example/config.yaml' should match the directory name.
- Adjust all keys/url's that points to 'home-assistant' to now point to your user/fork.
- Share your repository on the forums https://community.home-assistant.io/c/projects/9
- Do awesome stuff!
-->
## ![SBFspot Logo](https://user-images.githubusercontent.com/1931158/30831762-006ec650-a249-11e7-86e3-13d01b36dd5d.jpg)
## ToDo List
### Fix
map directories to /addon/??
configure gui to SBFspot.cfg and SBFspotUpload.cfg??
### Configure
built in MQTT conections??
built in MariaDB ( point to and add database and user in existing addon??
## ToDo end
SBFspot addon for supervised Home Assistant, based an open source project located at github ([SBFspot on github](https://github.com/SBFspot/SBFspot)).
This project creates an addon install for Home assistant users using the latest release of SBFspot as a docker install.
# Installation and configuration
Add ([this respository](https://github.com/HABuild/hassio_addons)) to Home Assistant via the superviser > new respository menu > add respository
Fill in the config details to setup Inverter connection, Database, MQTT , and Upload API.
Start the addon
# Special Thanks To:
SBFspot
https://github.com/SBFspot/SBFspot
and
nakla for the dockerfile
https://github.com/nakla/sbfspot
and
LauR3y for sbfspot addon
https://github.com/LauR3y/hassio-addons
## SBFspot Readme ([SBFspot on github](https://github.com/SBFspot/SBFspot)).
![SBFspot Logo](https://user-images.githubusercontent.com/1931158/30831762-006ec650-a249-11e7-86e3-13d01b36dd5d.jpg)
Translation by Google: [[NL](https://translate.google.com/translate?act=url&depth=1&hl=nl&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&sp=nmt4&tl=nl&u=https://github.com/SBFspot/SBFspot)] - [[FR](https://translate.google.com/translate?act=url&depth=1&hl=nl&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&sp=nmt4&tl=fr&u=https://github.com/SBFspot/SBFspot)] - [[DE](https://translate.google.com/translate?act=url&depth=1&hl=nl&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&sp=nmt4&tl=de&u=https://github.com/SBFspot/SBFspot)] - [[ES](https://translate.google.com/translate?act=url&depth=1&hl=nl&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&sp=nmt4&tl=es&u=https://github.com/SBFspot/SBFspot)] - [[IT](https://translate.google.com/translate?act=url&depth=1&hl=nl&ie=UTF8&prev=_t&rurl=translate.google.com&sl=en&sp=nmt4&tl=it&u=https://github.com/SBFspot/SBFspot)]
### **Introduction**
SBFspot, formerly known as SMAspot, is an open source project to get actual and archive data out of an SMA® inverter over Bluetooth or Ethernet (Speedwire®) It works on either Linux ([Raspberry Pi](http://www.raspberrypi.org)) and Windows.
### **What it does**
SBFspot connects via Bluetooth or Ethernet to your SMA® solar/battery inverter and reads Archive Day/Month Power generation, user/installer events and the actual (spot) data. The collected data is stored in a SQL database (SQLite/MySQL/MariaDB) or SMA® compatible .csv files.
A separate service/daemon uploads the collected data to [PVoutput.org](https://pvoutput.org)
### **Known bugs and limitations**
For a list of known bugs, consult the [issues](https://github.com/SBFspot/SBFspot/issues). If you find a bug, please create an [issue](https://github.com/SBFspot/SBFspot/issues).
### **Documentation**
Refer to the [Wiki](https://github.com/SBFspot/SBFspot/wiki) for documentation and FAQ.
### **Special thanks to:**
* S. Pittaway: Author of ["NANODE SMA PV MONITOR"](https://github.com/stuartpittaway/nanodesmapvmonitor) on which this project is based.
* W. Simons : Early adopter, main tester and SMAdata2® Protocol analyzer
* G. Schnuff : SMAdata2® Protocol analyzer
* T. Frank: Speedwire® support
* Snowmiss: User manual
* All other users for their contribution - in any form - to the success of this project
### **Donations**
SBFspot is a free tool, developed during personal free time. If you like it, consider a donation.
If you click on the button below, you will be taken to the secure PayPal Web site. You don't need to have a paypal account in order to make a donation.
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3R5JSRCXBGSLQ)
### **License**
[Attribution - NonCommercial - ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)](https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode)
In short, you are free:
* to Share => to copy, distribute and transmit the work
* to Remix => to adapt the work
Under the following conditions:
* **Attribution:** You must attribute the work in the manner specified by the author or Licensor (but not in any way that suggests that they endorse you or your use of the work).
* **Noncommercial:** You may not use this work for commercial purposes.
* **Share Alike:** If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.
### **Disclaimer**
A user of SBFspot software acknowledges that he or she is receiving this software on an "as is" basis and the user is not relying on the accuracy or functionality of the software for any purpose. The user further acknowledges that any use of this software will be at his own risk and the copyright owner accepts no responsibility whatsoever arising from the use or application of the software.
SMA, Speedwire are registered trademarks of [SMA Solar Technology AG](http://www.sma.de/en/company/about-sma.html)
[maintenance-shield]: https://img.shields.io/maintenance/yes/2022.svg
[project-stage-shield]: https://img.shields.io/badge/project%20stage-production%20testing-red.svg
[release-shield]: https://img.shields.io/badge/version-2022.repo-blue.svg
[release]: https://github.com/hassio-addons/addon-ssh/tree/2022.repo

9
example/CHANGELOG.md Normal file
View file

@ -0,0 +1,9 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->
## 1.1.0
- Updates
## 1.0.0
- Initial release

7
example/DOCS.md Normal file
View file

@ -0,0 +1,7 @@
# Home Assistant Add-on: Example add-on
## How to use
This add-on really does nothing. It is just an example.
When started it will print the configured message or "Hello world" in the log.

12
example/Dockerfile Normal file
View file

@ -0,0 +1,12 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM
# Execute during the build of the image
ARG TEMPIO_VERSION BUILD_ARCH
RUN \
curl -sSLf -o /usr/bin/tempio \
"https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
# Copy root filesystem
COPY rootfs /

15
example/README.md Normal file
View file

@ -0,0 +1,15 @@
# Home Assistant Add-on: Example add-on
_Example add-on to use as a blueprint for new add-ons._
![Supports aarch64 Architecture][aarch64-shield]
![Supports amd64 Architecture][amd64-shield]
![Supports armhf Architecture][armhf-shield]
![Supports armv7 Architecture][armv7-shield]
![Supports i386 Architecture][i386-shield]
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg

11
example/build.yaml Normal file
View file

@ -0,0 +1,11 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
build_from:
aarch64: "ghcr.io/home-assistant/aarch64-base:3.14"
labels:
org.opencontainers.image.title: "${BUILD_NAME}"
org.opencontainers.image.description: "Example add-on to use as a blueprint for new add-ons."
org.opencontainers.image.source: "https://github.com/habuild/"
org.opencontainers.image.licenses: "Apache License 2.0"
args:
TEMPIO_VERSION: "2021.09.0"

17
example/config.yaml Normal file
View file

@ -0,0 +1,17 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
name: Example add-on
version: "1.1.0"
slug: example
description: Example add-on
url: "https://github.com/habuild/sbfspot_addon/tree/main/example"
arch:
- armhf
- armv7
- aarch64
- amd64
init: false
options:
message: "Hello world..."
schema:
message: "str?"
image: "ghcr.io/habuild/{arch}-addon-example"

BIN
example/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
example/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree when example fails
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,19 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start the example service
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
# Add your code here
# Declare variables
declare message
## Get the 'message' key from the user config options.
message=$(bashio::config 'message')
## Print the message the user supplied, defaults to "Hello World..."
bashio::log.info "${message:="Hello World..."}"
## Run your program
# exec my_program --with-params

View file

@ -0,0 +1,4 @@
configuration:
message:
name: Message
description: The message that will be printed to the log when starting this example add-on.

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

4
repository.yaml Normal file
View file

@ -0,0 +1,4 @@
# https://developers.home-assistant.io/docs/add-ons/repository#repository-configuration
name: SBFspot for HA
url: 'https://github.com/habuild/hassio_addons'
maintainer: HasQT <https://community.home-assistant.io/u/hasqt>

7
sbfspot/CHANGELOG.md Normal file
View file

@ -0,0 +1,7 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->
## 2022.3.1
![Version](https://img.shields.io/badge/dynamic/yaml?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fhassio_addons%2Fmaster%2Fsbfspot%2Fconfig.yaml)
- Initial release

3
sbfspot/DOCS.md Normal file
View file

@ -0,0 +1,3 @@
[![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fhabuild%2Fhassio_addons)
[Readme](https://github.com/habuild/hassio-addons/blob/master/README.md)

113
sbfspot/Dockerfile Normal file
View file

@ -0,0 +1,113 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
ARG BUILD_FROM
FROM $BUILD_FROM AS builder
# Execute during the build of the image
ARG TEMPIO_VERSION BUILD_ARCH
RUN \
curl -sSLf -o /usr/bin/tempio \
"https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
ENV LANG C.UTF-8
ENV MQTT_ENABLE 1
# Copy root filesystem
COPY rootfs /
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# install requirements
RUN apk update && apk upgrade && apk add --no-cache git g++ make mysql-dev bluez-dev boost-dev curl-dev mosquitto-clients openrc mariadb-dev
# download and build SBFspot
RUN \
cd /tmp \
&& git clone https://github.com/habuild/SBFspot.git . \
&& cd SBFspot \
&& make mysql \
&& cd .. \
&& cd SBFspotUploadDaemon \
&& make mysql
# runtinme container
FROM $BUILD_FROM
ARG TEMPIO_VERSION BUILD_ARCH
RUN \
curl -sSLf -o /usr/bin/tempio \
"https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
RUN apk --no-cache add boost-date_time bluez-libs libstdc++ tzdata mariadb-common mariadb-connector-c ncurses-libs libcurl mosquitto-clients openrc
# openrc changes
RUN \
# Tell openrc its running inside a container, till now that has meant LXC
sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf &&\
# Tell openrc loopback and net are already there, since docker handles the networking
echo 'rc_provide="loopback net"' >> /etc/rc.conf &&\
# no need for loggers
sed -i 's/^#\(rc_logger="YES"\)$/\1/' /etc/rc.conf &&\
# can't get ttys unless you run the container in privileged mode
sed -i '/tty/d' /etc/inittab &&\
# can't set hostname since docker sets it
sed -i 's/hostname $opts/# hostname $opts/g' /etc/init.d/hostname &&\
# can't mount tmpfs since not privileged
sed -i 's/mount -t tmpfs/# mount -t tmpfs/g' /lib/rc/sh/init.sh &&\
# can't do cgroups
sed -i 's/cgroup_add_service /# cgroup_add_service /g' /lib/rc/sh/openrc-run.sh
RUN rc-status
RUN mkdir -p /run/openrc && touch /run/openrc/softlevel
# Copy data for add-on
COPY rootfs /
COPY --from=builder /tmp/SBFspot/mysql/bin/SBFspot /tmp/SBFspot/mysql/bin/SBFspot
COPY --from=builder /tmp/SBFspotUploadDaemon/mysql/bin/SBFspotUploadDaemon /tmp/SBFspotUploadDaemon/mysql/bin/SBFspotUploadDaemon
COPY --from=builder /tmp/SBFspot/date_time_zonespec.csv /tmp/SBFspot/date_time_zonespec.csv
COPY --from=builder /tmp/SBFspot/TagList* /tmp/SBFspot/
RUN cp /tmp/SBFspot/mysql/bin/SBFspot /
RUN cp /tmp/SBFspotUploadDaemon/mysql/bin/SBFspotUploadDaemon /
RUN cp /tmp/SBFspot/date_time_zonespec.csv /
RUN cp /tmp/SBFspot/TagList* /
RUN chmod a+x /generateConfig.sh /openrc-restart-crashed.sh /SBFspot /SBFspotUploadDaemon /etc/init.d/SBFspotUploadDaemon.service /SBFspot.default.cfg /SBFspotUpload.default.cfg
# --- install cron ---
# set shell
RUN echo 'SHELL=/bin/bash' > /etc/crontabs/root
# daily data SBFspot
RUN echo '*/5 6-22 * * * /SBFspot -v -ad1 -am0 -ae0 -mqtt > /dev/stdout' >> /etc/crontabs/root
# monthly data SBFspot
RUN echo '55 05 * * * /SBFspot -v -sp0 -ad0 -am1 -ae1 -finq > /dev/stdout' >> /etc/crontabs/root
# openrc restart crashed services
RUN echo '*/15 * * * * /openrc-restart-crashed.sh -- SBFspotUploadDaemon.service > /dev/stdout' >> /etc/crontabs/root
# openrc status logging
RUN echo '*/5 * * * * rc-status -s > /dev/stdout' >> /etc/crontabs/root
# install service
RUN rc-update add SBFspotUploadDaemon.service default
# Labels
LABEL \
io.hass.name="SBFspot" \
io.hass.description="Home Assitant addon for Bluetooth SBFspot, is an open source project to get actual and archive data out of an SMA® inverter over Bluetooth or Ethernet (Speedwire®)" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Hasqt <https://community.home-assistant.io/u/hasqt>" \
org.label-schema.description="Home Assitant addon for Bluetooth SBFspot, is an open source project to get actual and archive data out of an SMA® inverter over Bluetooth or Ethernet (Speedwire®)" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="SBFspot" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://github.com/habuild/hassio-addons/tree/master/sbfspot" \
org.label-schema.usage="https://github.com/habuild/hassio-addons/tree/master/sbfspot/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/habuild/hassio-addons" \
org.label-schema.vendor="Hasqt"
#CMD [ "/run.sh" ] not needed with rootfs/etc/init.d/{slug}run

58
sbfspot/README.md Normal file
View file

@ -0,0 +1,58 @@
# Community Hass.io Add-ons: SBFspot
![project-stage-shield] ![Project Maintenance][maintenance-shield]
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
[maintenance-shield]: https://img.shields.io/maintenance/yes/2022.svg
![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fsbfspot_addon%2Fmaster%2Fsbfspot%2Fconfig.json)
![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fsbfspot_addon%2Fmaster%2Fsbfspot%2Fconfig.json)
This [home assistant](https://www.home-assistant.io/getting-started/) add-on provides the installation, configuration, and integration for the **Bluetooth** version of [SBFspot 3.9.3](https://github.com/habuild/sbfspot_addon/tree/master/sbfspot).
This add-on installs a cron service for SPFspot uploader at 5 minutely daytime interval, [PVoutput](https://pvoutput.org/) account and API are required, it also requires an SQL database like Mariadb.
It also sends a MQTT message to home assistant, therefore a MQTT broker is required.
# Installation
### Initial database creation.
Download and import either [No Drop DB create](https://github.com/habuild/sbfspot_addon/blob/master/sbfspot/.images/CreateMySQLDB_no_drop.sql) **or** [Create My SQL.sql](https://github.com/SBFspot/SBFspot/blob/master/SBFspot/CreateMySQLDB.sql) in [phpMyAdmin](https://github.com/hassio-addons/addon-phpmyadmin) to create your database. **IF** you haven't already created the database previously, use the NO Drop version. You will also need to add the Database and User/Password to MariaDB and allocate the port.
![screenshot](https://raw.githubusercontent.com/habuild/sbfspot_addon/master/.images/MariaDB%20setup.PNG)
### MQTT
[sbfspot_sensors.yaml](https://github.com/habuild/sbfspot_addon/blob/master/sbfspot/.images/sbfspot_sensors.yaml) I use packages to include these yaml sensors. You will need to change to match your plant name and serial as you have set in the add-on configuration options.
**Although** the [configuration options](https://github.com/habuild/sbfspot_addon/blob/master/sbfspot/.images/Example_Config.yaml) list a MQTT host. The MQTT Host, Username, and Password need to be hardcoded into the **MQTT_PublisherArgs:** The **{topic}** and **{{message}}** will be picked up from options.
**MQTT_PublisherArgs:** **'-h Your_MQTT_Hostname -u Your_MQTT_Username -P Your_MQTT_password -t {topic} -m "{{message}}" -d -r'**
**-d** is for MQTT debug in log.
**-r** is to retain messages.
### Example Configuration Options.
can be copy/pasted as [Example Config](https://github.com/habuild/sbfspot_addon/blob/master/sbfspot/.images/Example_Config.yaml) or entered via UI
![Example Options](https://raw.githubusercontent.com/habuild/sbfspot_addon/master/.images/Example_config_png.PNG)
### Data paths
In docker the /data/ path arrives at /usr/share/hassio/addons/data/slug#_sbfspot on the host.
### Upload logs
TODO Need to grep? or bashio the upload log file back into HA log. The log file here may need to be cleaned up manually.
### **Link to SBFspot Documentation**
Refer to the [Wiki](https://github.com/SBFspot/SBFspot/wiki) for documentation and FAQ.
### **Special thanks to:**
* LauR3y/hassio-addons which this version is cleaned up from.
* The SBFspot team for SPFspot.
![Supports aarch64 Architecture][aarch64-shield]
![Supports armhf Architecture][armhf-shield]
![Supports armv7 Architecture][armv7-shield]
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg

13
sbfspot/build.yaml Normal file
View file

@ -0,0 +1,13 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
build_from:
aarch64: "ghcr.io/home-assistant/aarch64-base:3.14"
armhf: "ghcr.io/home-assistant/armhf-base:3.14"
armv7: "ghcr.io/home-assistant/armv7-base:3.14"
labels:
org.opencontainers.image.title: "SBFspot for Home Assistant"
org.opencontainers.image.description: "SBFspot from a blueprint for new add-ons."
org.opencontainers.image.source: "https://github.com/habuild"
org.opencontainers.image.licenses: "Apache License 2.0"
args:
TEMPIO_VERSION: "2021.09.0"

112
sbfspot/config.json Normal file
View file

@ -0,0 +1,112 @@
{
"name": "SBFspot",
"version": "2022.3.1",
"slug": "sbfspot",
"description": "Manage SBFspot with a simple interface",
"url": "https://github.com/habuild/hassio_addons/tree/main/sbfspot",
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
"init": false,
"host_network": true,
"privileged": ["SYS_MODULE"],
"devices": ["/dev/ttyAMA0"],
"options": {
"BTAddress": null,
"Password": "0000",
"MIS_Enabled": 0,
"Plantname": "MyPlant",
"OutputPath": "/data/sbfspot/%Y",
"OutputPathEvents": "/data/sbfspot/%Y/events",
"Latitude": null,
"Longitude": null,
"CalculateMissingSpotValues": 1,
"DateTimeFormat": "%d/%m/%Y %H:%M:%S",
"DateFormat": "%d/%m/%Y",
"DecimalPoint": "comma",
"TimeFormat": "%H:%M:%S",
"SynchTime": 0,
"SynchTimeLow": 1,
"SynchTimeHigh": 3600,
"SunRSOffset": 900,
"Locale": "en-US",
"Timezone": "Europe/Brussels",
"BTConnectRetries": 10,
"CSV_Export": 0,
"CSV_ExtendedHeader": 1,
"CSV_Header": 1,
"CSV_SaveZeroPower": 1,
"CSV_Delimiter": "semicolon",
"CSV_Spot_TimeSource": "Inverter",
"CSV_Spot_WebboxHeader": 0,
"SQL_Database": null,
"SQL_Hostname": null,
"SQL_Port": "3306",
"SQL_Username": null,
"SQL_Password": null,
"MQTT_Publisher": "/usr/bin/mosquitto_pub",
"MQTT_Host": null,
"MQTT_Port": null,
"MQTT_Username": "!secret mqtt_user",
"MQTT_Password": "!secret has_pass",
"MQTT_Topic": "homeassistant/sbfspot_{plantname}/sbfspot_{serial}",
"MQTT_ItemFormat": "\"{key}\": {value}",
"MQTT_ItemDelimiter": "comma",
"MQTT_PublisherArgs": "-h {host} -u {MQTT_Username} -P {MQTT_Password} -t {topic} -m \"{{message}}\" -d",
"MQTT_Data": "Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,PACTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2",
"LogDir": "/data/sbfspot/log",
"LogLevel": "info",
"PVoutput_SID": null,
"PVoutput_Key": null,
"MQTT_ENABLE": "1"
},
"schema": {
"BTAddress": "str",
"Password": "str",
"MIS_Enabled": "int",
"Plantname": "str",
"OutputPath": "str",
"OutputPathEvents": "str",
"Latitude": "float",
"Longitude": "float",
"CalculateMissingSpotValues": "int",
"DateTimeFormat": "str",
"DateFormat": "str",
"DecimalPoint": "str",
"TimeFormat": "str",
"SynchTime": "int",
"SynchTimeLow": "int",
"SynchTimeHigh": "int",
"SunRSOffset": "int",
"Locale": "str",
"Timezone": "str",
"BTConnectRetries": "int",
"CSV_Export": "int",
"CSV_ExtendedHeader": "int",
"CSV_Header": "int",
"CSV_SaveZeroPower": "int",
"CSV_Delimiter": "str",
"CSV_Spot_TimeSource": "str",
"CSV_Spot_WebboxHeader": "int",
"SQL_Database": "str",
"SQL_Hostname": "str",
"SQL_Port": "str",
"SQL_Username": "str",
"SQL_Password": "str",
"MQTT_Publisher": "str",
"MQTT_Host": "str",
"MQTT_Port": "str?",
"MQTT_Username": "str?",
"MQTT_Password": "str?",
"MQTT_Topic": "str",
"MQTT_ItemFormat": "str",
"MQTT_ItemDelimiter": "str",
"MQTT_PublisherArgs": "str",
"MQTT_Data": "str",
"LogDir": "str",
"LogLevel": "str",
"PVoutput_SID": "str",
"PVoutput_Key": "str",
"MQTT_ENABLE": "int"
},
"image": "ghcr.io/habuild/{arch}-addon-sbfspot"
}

BIN
sbfspot/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

BIN
sbfspot/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -0,0 +1,268 @@
################################################################################
# ____ ____ _____ _
# / ___|| __ )| ___|__ _ __ ___ | |_
# \___ \| _ \| |_ / __| '_ \ / _ \| __|
# ___) | |_) | _|\__ \ |_) | (_) | |_
# |____/|____/|_| |___/ .__/ \___/ \__|
# |_|
#
# SBFspot.cfg - Configuration file for SBFspot.exe
# SBFspot - Yet another tool to read power production of SMA solar inverters
# (c)2012-2021, SBF
#
# DISCLAIMER:
# A user of SBFspot software acknowledges that he or she is receiving this
# software on an "as is" basis and the user is not relying on the accuracy
# or functionality of the software for any purpose. The user further
# acknowledges that any use of this software will be at his own risk
# and the copyright owner accepts no responsibility whatsoever arising from
# the use or application of the software.
#
# SMA and Speedwire are registered trademarks of SMA Solar Technology AG
################################################################################
# SMA Inverter's Bluetooth address
# Windows: sbfspot -scan
# Linux : hcitool scan
# IMPORTANT FOR SPEEDWIRE USERS: COMMENT OUT BTADDRESS (PUT # IN FRONT)
BTAddress=00:00:00:00:00:00
# If multiple local BT adapters are available, select the one to use
#LocalBTAddress=00:00:00:00:00:00
# SMA Inverter's Speedwire IP address
# If IP_Address is not set or is 0.0.0.0 SBFspot will try to detect the speedwire inverter by broadcast
# If IP_Address is set to a valid IP, SBFspot will try to connect directly to that IP without broadcast detection
# Multiple IP addresses can be provided (comma separated)
#IP_Address=0.0.0.0
# User password (default 0000)
Password=0000
# MIS_Enabled (Multi Inverter Support: Default=0 Disabled)
# +------------+-------+-------------+
# | #Inverters | NetID | MIS_Enabled |
# +------------+-------+-------------+
# | 1 | 1 | Don't Care |
# +------------+-------+-------------+
# | 1 | >1 | 0 |
# +------------+-------+-------------+
# | >1 | >1 | 1 |
# +------------+-------+-------------+
MIS_Enabled=0
# Plantname
Plantname=MyPlant
# OutputPath (Place to store CSV files)
#
# Windows: C:\Users\Public\SMAdata\%Y
# Linux : /home/pi/smadata/%Y
# %Y %m and %d will be expanded to Year Month and Day
OutputPath=/home/pi/smadata/%Y
# OutputPathEvents (Place to store CSV files for events)
# If omitted, OutputPath is used
OutputPathEvents=/home/pi/smadata/%Y/Events
# Position of pv-plant http://itouchmap.com/latlong.html
# Example for Ukkel, Belgium
Latitude=50.80
Longitude=4.33
# Calculate Missing SpotValues
# If set to 1, values not provided by inverter will be calculated
# eg: Pdc1 = Idc1 * Udc1
CalculateMissingSpotValues=1
# DateTimeFormat (default %d/%m/%Y %H:%M:%S)
# For details see strftime() function
# http://www.cplusplus.com/reference/clibrary/ctime/strftime/
DateTimeFormat=%d/%m/%Y %H:%M:%S
# DateFormat (default %d/%m/%Y)
DateFormat=%d/%m/%Y
# DecimalPoint (comma/point default comma)
DecimalPoint=comma
# TimeFormat (default %H:%M:%S)
TimeFormat=%H:%M:%S
# SynchTime (0-30 - 0=disabled, 1=once a day (default), 7=once a week, 30=once a month)
# If set to non-zero value, the plant time is synchronised with local host time
# Some inverters don't have a real-time clock
SynchTime=1
# SynchTimeLow (1-120 - default 1)
# SynchTimeHigh (1200-3600 - default 3600)
# Plant time is adjusted to local host time when SynchTime=1 and
# time difference is between SynchTimeLow and SynchTimeHigh limits
SynchTimeLow=1
SynchTimeHigh=3600
# SunRSOffset
# Offset to start before sunrise and end after sunset (0-3600 - default 900 seconds)
SunRSOffset=900
# Locale
# Translate Entries in CSV files
# Supported locales: de-DE;en-US;fr-FR;nl-NL;es-ES;it-IT
# Default en-US
Locale=en-US
# Timezone
# Select the right timezone in date_time_zonespec.csv
# e.g. Timezone=Europe/Brussels
Timezone=Europe/Brussels
# BTConnectRetries
# Number of Bluetooth Connection attempts (1-15; Default=10)
BTConnectRetries=10
###########################
### CSV Export Settings ###
###########################
# With CSV_* settings you can define the CSV file format
# CSV_Export (default 1 = Enabled)
# Enables or disables the CSV Export functionality
CSV_Export=1
# CSV_ExtendedHeader (default 1 = On)
# Enables or disables the SMA extended header info (8 lines)
# isep=;
# Version CSV1|Tool SBFspot|Linebreaks CR/LF|Delimiter semicolon|Decimalpoint comma|Precision 3
# etc...
# This is usefull for manual data upload to pvoutput.org
CSV_ExtendedHeader=1
# CSV_Header (default 1 = On)
# Enables or disables the CSV data header info (1 line)
# dd/MM/yyyy HH:mm:ss;kWh;kW
# This is usefull for manual data upload to pvoutput.org
# If CSV_ExtendedHeader is enabled, CSV_Header is also enabled
CSV_Header=1
# CSV_SaveZeroPower (default 1 = On)
# When enabled, daily csv files contain all data from 00:00 to 23:55
# This is usefull for manual data upload to pvoutput.org
CSV_SaveZeroPower=1
# CSV_Delimiter (comma/semicolon default semicolon)
CSV_Delimiter=semicolon
# CSV_Spot_TimeSource (Inverter|Computer default Inverter)
CSV_Spot_TimeSource=Inverter
# CSV_Spot_WebboxHeader (Default 0 = Off)
# When enabled, use Webbox style header (DcMs.Watt[A];DcMs.Watt[B]...)
CSV_Spot_WebboxHeader=0
###########################
### SQL DB Settings ###
###########################
# SQLite
# SQL_Database (Fullpath to SQLite DB)
# Windows: C:\Users\Public\SMAdata\SBFspot.db
# Linux : /home/pi/smadata/SBFspot.db
SQL_Database=/home/pi/smadata/SBFspot.db
# MySQL
#SQL_Database=SBFspot
#SQL_Hostname=<Network Name> or <IP-address>
#SQL_Port=3306
#SQL_Username=SBFspotUser
#SQL_Password=SBFspotPassword
#########################
### MQTT Settings ###
#########################
# Full path to mosquitto_pub executable
# Linux: sudo apt-get install mosquitto-clients
MQTT_Publisher=/usr/bin/mosquitto_pub
# Windows: Download and install mosquitto clients from https://mosquitto.org/download/
# Mosquitto 64-bit on Windows 64-bit
# MQTT_Publisher=%ProgramW6432%\\mosquitto\\mosquitto_pub.exe
# Mosquitto 32-bit on Windows 32-bit
# MQTT_Publisher=%ProgramFiles%\\mosquitto\\mosquitto_pub.exe
# IP address or DNS name of MQTT Broker
# Don't use test broker for production environments
MQTT_Host=test.mosquitto.org
# MQTT_Host=broker.hivemq.com
# Port (Optional)
#MQTT_Port=
# Topic Name
# When using public broker like test.mosquitto.org make sure to define a unique topic name
# by appending the serial number of the inverter to avoid you receive data of another SBFspot user.
MQTT_Topic=sbfspot_{serial}
#MQTT_Topic=sbfspot_{plantname}/sma_{serial}
# Format of message items to be sent
# JSON: MQTT_ItemFormat="{key}": {value}
# TEXT: MQTT_ItemFormat={key}:{value}
# XML: MQTT_ItemFormat=<item name="{key}" value="{value}" />
MQTT_ItemFormat="{key}": {value}
# MQTT_ItemDelimiter (none|blank|comma|semicolon default comma)
# JSON: MQTT_ItemDelimiter=comma
# TEXT: MQTT_ItemDelimiter=semicolon
# XML : MQTT_ItemDelimiter=none
MQTT_ItemDelimiter=comma
# Mandatory arguments for mosquitto_pub executable
# JSON: MQTT_PublisherArgs=-h {host} -t {topic} -m "{{message}}"
# TEXT: MQTT_PublisherArgs=-h {host} -t {topic} -m "{message}"
# XML : MQTT_PublisherArgs=-h {host} -t {topic} -m "<mqtt_message>{message}</mqtt_message>"
MQTT_PublisherArgs=-h {host} -t {topic} -r -m "{{message}}"
# Data to be published (comma delimited)
MQTT_Data=Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,PACTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2
# Possible keywords are (if supported by your inverter):
# SBFspot Alias Code Description
# ====================================================================================
# Timestamp Current date/time
# InvTime Inverter date/time
# SunRise Sunrise time
# SunSet Sunset time
# InvSerial Serial Number
# InvName NameplateLocation Device name
# InvClass NameplateMainModel Device class
# InvType NameplateModel Device type
# InvSwVer NameplatePkgRev Software package
# InvStatus OperationHealth Condition
# InvTemperature CoolsysTmpNom Operating condition temperatures
# InvGridRelay OperationGriSwStt Grid relay/contactor
# ETotal MeteringTotWhOut Total yield
# EToday MeteringDyWhOut Day yield
# PACTot GridMsTotW Power
# PDC1/PDC2 DcMsWatt DC power input string 1/2
# UDC1/UDC2 DcMsVol DC voltage input string 1/2
# IDC1/IDC2 DcMsAmp DC current input string 1/2
# PDCTot DcMsWatt DC power all strings
# OperTm MeteringTotOpTms Operating time
# FeedTm MeteringTotFeedTms Feed-in time
# PAC1 GridMsWphsA Power L1
# PAC2 GridMsWphsB Power L2
# PAC3 GridMsWphsC Power L3
# UAC1 GridMsPhVphsA Grid voltage phase L1
# UAC2 GridMsPhVphsB Grid voltage phase L2
# UAC3 GridMsPhVphsC Grid voltage phase L3
# IAC1 GridMsAphsA_1 Grid current phase L1
# IAC2 GridMsAphsB_1 Grid current phase L2
# IAC3 GridMsAphsC_1 Grid current phase L3
# GridFreq GridMsHz Grid frequency
# BTSignal BTSignal Bluetooth signal strength
# BatTmpVal BatTmpVal Battery temperature
# BatVol BatVol Battery voltage
# BatAmp BatAmp Battery current
# BatChaStt BatChaStt Current battery charge status

View file

@ -0,0 +1,54 @@
################################################################################
# SBFspotUpload.cfg - Configuration file for SBFspotUploadService/Daemon
# (c)2012-2021, SBF (https://github.com/SBFspot/SBFspot)
#
# DISCLAIMER:
# A user of SBFspotUploadService/Daemon software acknowledges that he or she is
# receiving this software on an "as is" basis and the user is not relying on
# the accuracy or functionality of the software for any purpose. The user
# further acknowledges that any use of this software will be at his own risk
# and the copyright owner accepts no responsibility whatsoever arising from
# the use or application of the software.
#
################################################################################
################################
### Log Settings ###
################################
# Windows: C:\Users\Public\SMAdata\Logs
# Linux : /var/log/sbfspot.3
#LogDir=C:\Users\Public\SMAdata\Logs
LogDir=/var/log/sbfspot.3
#LogLevel=debug|info|warning|error (default info)
LogLevel=info
################################
### PVoutput Upload Settings ###
################################
#PVoutput_SID (PVoutput_System_ID)
#Map inverters to PVoutput System ID's
#PVoutput_SID=SerialNmbrInverter_1:PVoutput_System_ID_1,SerialNmbrInverter_2:PVoutput_System_ID_2
#e.g. PVoutput_SID=200212345:4321
PVoutput_SID=
#PVoutput_Key
#Sets PVoutput API Key
PVoutput_Key=
################################
### SQL DB Settings ###
################################
# SQL_Database (Fullpath to SQLite DB)
# Windows: C:\Users\Public\SMAdata\SBFspot.db
# Linux : /home/pi/smadata/SBFspot.db
#SQL_Database=C:\Users\Public\SMAdata\SBFspot.db
SQL_Database=/home/pi/smadata/SBFspot.db
# Reserved for MySQL
#SQL_Database=SBFspot
#SQL_Hostname=<Network Name> or <IP-address>
#SQL_Port=3306
#SQL_Username=SBFspotUser
#SQL_Password=SBFspotPassword

View file

@ -0,0 +1,36 @@
#!/sbin/openrc-run
description="SBFspot upload daemon"
#pidfile="/run/SBFspotUploadDaemon.pid"
command="/SBFspotUploadDaemon"
command_opts=" -c /SBFspotUpload.cfg"
depend() {
need net
}
start()
{
ebegin "Starting SBFspotUploadDaemon"
start-stop-daemon --start --background \
--exec $command \
-- $command_opts \
#--make-pidfile --pidfile $pidfile
eend $?
}
stop() {
ebegin "Stopping SBFspotUploadDaemon"
start-stop-daemon --stop \
--exec $command \
#--pidfile $pidfile
eend $?
}
reload() {
ebegin "Reloading SBFspotUploadDaemon"
start-stop-daemon --exec $command \
#--pidfile $pidfile \
-s 1
eend $?
}

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S1
# ==============================================================================
# Take down the S6 supervision tree when SBFspot fails
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,34 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start the SBFspot service
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
#!/bin/sh
set -e
echo 'Show all runlevels and their services.'
rc-status -a
echo 'Show all services.'
rc-status -s
# --- GENERATE CONFIG --
echo "PWD is current directory $(pwd)"
cd /
echo "PWD is current directory $(pwd)"
./generateConfig.sh SBFspot.cfg SBFspotUpload.cfg
#chmod a+x SBFspot.cfg SBFspotUpload.cfg
# ---- RUN ----
# start service
echo 'Starting daemon'
rc-service SBFspotUploadDaemon.service start
# cron
echo 'Starting cron in foreground'
/usr/sbin/crond -f
# echo 'Starting daemon'
# ./SBFspotUploadDaemon

View file

@ -0,0 +1,309 @@
CFG_PATH=$1
CFG_PATH_UPLOAD=$2
CONFIG_PATH=/data/options.json
echo "Generating $CFG_PATH & $CFG_PATH_UPLOAD"
CONFIG_BTADDRESS="$(jq --raw-output '.BTAddress' $CONFIG_PATH)"
CONFIG_PASSWORD="$(jq --raw-output '.Password' $CONFIG_PATH)"
CONFIG_MSI_ENABLED="$(jq --raw-output '.MIS_Enabled' $CONFIG_PATH)"
CONFIG_PLANTNAME="$(jq --raw-output '.Plantname' $CONFIG_PATH)"
CONFIG_OUTPUTPATH="$(jq --raw-output '.OutputPath' $CONFIG_PATH)"
CONFIG_OUTPUTPATHEVENTS="$(jq --raw-output '.OutputPathEvents' $CONFIG_PATH)"
CONFIG_LATITUDE="$(jq --raw-output '.Latitude' $CONFIG_PATH)"
CONFIG_LONGITUDE="$(jq --raw-output '.Longitude' $CONFIG_PATH)"
CONFIG_CALCULATEMISSINGSPOTVALUES="$(jq --raw-output '.CalculateMissingSpotValues' $CONFIG_PATH)"
CONFIG_DATETIMEFORMAT="$(jq --raw-output '.DateTimeFormat' $CONFIG_PATH)"
CONFIG_DATEFORMAT="$(jq --raw-output '.DateFormat' $CONFIG_PATH)"
CONFIG_DECIMALPOINT="$(jq --raw-output '.DecimalPoint' $CONFIG_PATH)"
CONFIG_TIMEFORMAT="$(jq --raw-output '.TimeFormat' $CONFIG_PATH)"
CONFIG_SYNCHTIME="$(jq --raw-output '.SynchTime' $CONFIG_PATH)"
CONFIG_SYNCHTIMELOW="$(jq --raw-output '.SynchTimeLow' $CONFIG_PATH)"
CONFIG_SYNCHTIMEHIGH="$(jq --raw-output '.SynchTimeHigh' $CONFIG_PATH)"
CONFIG_SUNRSOFFSET="$(jq --raw-output '.SunRSOffset' $CONFIG_PATH)"
CONFIG_LOCALE="$(jq --raw-output '.Locale' $CONFIG_PATH)"
CONFIG_TIMEZONE="$(jq --raw-output '.Timezone' $CONFIG_PATH)"
CONFIG_BTCONNECTRETRIES="$(jq --raw-output '.BTConnectRetries' $CONFIG_PATH)"
CONFIG_CSV_EXPORT="$(jq --raw-output '.CSV_Export' $CONFIG_PATH)"
CONFIG_CSV_EXTENDEDHEADER="$(jq --raw-output '.CSV_ExtendedHeader' $CONFIG_PATH)"
CONFIG_CSV_HEADER="$(jq --raw-output '.CSV_Header' $CONFIG_PATH)"
CONFIG_CSV_SAVEZEROPOWER="$(jq --raw-output '.CSV_SaveZeroPower' $CONFIG_PATH)"
CONFIG_CSV_DELIMITER="$(jq --raw-output '.CSV_Delimiter' $CONFIG_PATH)"
CONFIG_CSV_SPOT_TIMESOURCE="$(jq --raw-output '.CSV_Spot_TimeSource' $CONFIG_PATH)"
CONFIG_CSV_SPOT_WEBBOXHEADER="$(jq --raw-output '.CSV_Spot_WebboxHeader' $CONFIG_PATH)"
CONFIG_SQL_DATABASE="$(jq --raw-output '.SQL_Database' $CONFIG_PATH)"
CONFIG_SQL_HOSTNAME="$(jq --raw-output '.SQL_Hostname' $CONFIG_PATH)"
CONFIG_SQL_PORT="$(jq --raw-output '.SQL_Port' $CONFIG_PATH)"
CONFIG_SQL_USERNAME="$(jq --raw-output '.SQL_Username' $CONFIG_PATH)"
CONFIG_SQL_PASSWORD="$(jq --raw-output '.SQL_Password' $CONFIG_PATH)"
CONFIG_MQTT_PUBLISHER="$(jq --raw-output '.MQTT_Publisher' $CONFIG_PATH)"
CONFIG_MQTT_HOST="$(jq --raw-output '.MQTT_Host' $CONFIG_PATH)"
CONFIG_MQTT_PORT="$(jq --raw-output '.MQTT_Port' $CONFIG_PATH)"
CONFIG_MQTT_USERNAME="$(jq --raw-output '.MQTT_Username' $CONFIG_PATH)"
CONFIG_MQTT_PASSWORD="$(jq --raw-output '.MQTT_Password' $CONFIG_PATH)"
CONFIG_MQTT_TOPIC="$(jq --raw-output '.MQTT_Topic' $CONFIG_PATH)"
CONFIG_MQTT_ITEMFORMAT="$(jq --raw-output '.MQTT_ItemFormat' $CONFIG_PATH)"
CONFIG_MQTT_ITEMDELIMITER="$(jq --raw-output '.MQTT_ItemDelimiter' $CONFIG_PATH)"
CONFIG_MQTT_PUBLISHERARGS="$(jq --raw-output '.MQTT_PublisherArgs' $CONFIG_PATH)"
CONFIG_MQTT_DATA="$(jq --raw-output '.MQTT_Data' $CONFIG_PATH)"
CONFIG_LOGDIR="$(jq --raw-output '.LogDir' $CONFIG_PATH)"
CONFIG_LOGLEVEL="$(jq --raw-output '.LogLevel' $CONFIG_PATH)"
CONFIG_PVOUTPUT_SID="$(jq --raw-output '.PVoutput_SID' $CONFIG_PATH)"
CONFIG_PVOUTPUT_KEY="$(jq --raw-output '.PVoutput_Key' $CONFIG_PATH)"
cat > $CFG_PATH <<EOL
################################################################################
# ____ ____ _____ _
# / ___|| __ )| ___|__ _ __ ___ | |_
# \___ \| _ \| |_ / __| '_ \ / _ \| __|
# ___) | |_) | _|\__ \ |_) | (_) | |_
# |____/|____/|_| |___/ .__/ \___/ \__|
# |_|
#
# SBFspot.cfg - Configuration file for SBFspot.exe
# SBFspot - Yet another tool to read power production of SMA<4D> solar inverters
# (c)2012-2018, SBF
#
# DISCLAIMER:
# A user of SBFspot software acknowledges that he or she is receiving this
# software on an "as is" basis and the user is not relying on the accuracy
# or functionality of the software for any purpose. The user further
# acknowledges that any use of this software will be at his own risk
# and the copyright owner accepts no responsibility whatsoever arising from
# the use or application of the software.
#
# SMA and Speedwire are registered trademarks of SMA Solar Technology AG
################################################################################
# SMA Inverter's Bluetooth address
# Windows: smaspot -scan
# Linux : hcitool scan
# IMPORTANT FOR SPEEDWIRE USERS: COMMENT OUT BTADDRESS (PUT # IN FRONT)
BTAddress=$CONFIG_BTADDRESS
# SMA Inverter's Speedwire IP address
# If IP_Address is not set or is 0.0.0.0 SBFspot will try to detect the speedwire inverter by broadcast
# If IP_Address is set to a valid IP, SBFspot will try to connect directly to that IP without broadcast detection
# Multiple IP addresses can be provided (comma separated)
#IP_Address=0.0.0.0
# User password (default 0000)
Password=$CONFIG_PASSWORD
# MIS_Enabled (Multi Inverter Support: Default=0 Disabled)
# +------------+-------+-------------+
# | #Inverters | NetID | MIS_Enabled |
# +------------+-------+-------------+
# | 1 | 1 | Don't Care |
# +------------+-------+-------------+
# | 1 | >1 | 0 |
# +------------+-------+-------------+
# | >1 | >1 | 1 |
# +------------+-------+-------------+
MIS_Enabled=$CONFIG_MSI_ENABLED
# Plantname
Plantname=$CONFIG_PLANTNAME
# OutputPath (Place to store CSV files)
#
# Windows: C:\Users\Public\SMAdata\%Y
# Linux : /home/pi/smadata/%Y
# %Y %m and %d will be expanded to Year Month and Day
OutputPath=$CONFIG_OUTPUTPATH
# OutputPathEvents (Place to store CSV files for events)
# If omitted, OutputPath is used
OutputPathEvents=$CONFIG_OUTPUTPATHEVENTS
# Position of pv-plant http://itouchmap.com/latlong.html
# Example for Ukkel, Belgium
Latitude=$CONFIG_LATITUDE
Longitude=$CONFIG_LONGITUDE
# Calculate Missing SpotValues
# If set to 1, values not provided by inverter will be calculated
# eg: Pdc1 = Idc1 * Udc1
CalculateMissingSpotValues=$CONFIG_CALCULATEMISSINGSPOTVALUES
# DateTimeFormat (default %d/%m/%Y %H:%M:%S)
# For details see strftime() function
# http://www.cplusplus.com/reference/clibrary/ctime/strftime/
DateTimeFormat=$CONFIG_DATETMEFORMAT
# DateFormat (default %d/%m/%Y)
DateFormat=$CONFIG_DATEFORMAT
# DecimalPoint (comma/point default comma)
DecimalPoint=$CONFIG_DECIMALPOINT
# TimeFormat (default %H:%M:%S)
TimeFormat=$CONFIG_TIMEFORMAT
# SynchTime (0-30 - 0=disabled, 1=once a day (default), 7=once a week, 30=once a month)
# If set to non-zero value, the plant time is synchronised with local host time
# Some inverters don't have a real-time clock
SynchTime=$CONFIG_SYNCHTIME
# SynchTimeLow (1-120 - default 1)
# SynchTimeHigh (1200-3600 - default 3600)
# Plant time is adjusted to local host time when SynchTime=1 and
# time difference is between SynchTimeLow and SynchTimeHigh limits
SynchTimeLow=$CONFIG_SYNCHTIMELOW
SynchTimeHigh=$CONFIG_SYNCHTIMEHIGH
# SunRSOffset
# Offset to start before sunrise and end after sunset (0-3600 - default 900 seconds)
SunRSOffset=$CONFIG_SUNRSOFFSET
# Locale
# Translate Entries in CSV files
# Supported locales: de-DE;en-US;fr-FR;nl-NL;es-ES;it-IT
# Default en-US
Locale=$CONFIG_LOCALE
# Timezone
# Select the right timezone in date_time_zonespec.csv
# e.g. Timezone=Europe/Brussels
Timezone=$CONFIG_TIMEZONE
# BTConnectRetries
# Number of Bluetooth Connection attempts (1-15; Default=10)
BTConnectRetries=$CONFIG_BTCONNECTRETRIES
###########################
### CSV Export Settings ###
###########################
# With CSV_* settings you can define the CSV file format
# CSV_Export (default 1 = Enabled)
# Enables or disables the CSV Export functionality
CSV_Export=$CONFIG_CSV_EXPORT
# CSV_ExtendedHeader (default 1 = On)
# Enables or disables the SMA extended header info (8 lines)
# isep=;
# Version CSV1|Tool SBFspot|Linebreaks CR/LF|Delimiter semicolon|Decimalpoint comma|Precision 3
# etc...
# This is usefull for manual data upload to pvoutput.org
CSV_ExtendedHeader=$CONFIG_CSV_EXTENDEDHEADER
# CSV_Header (default 1 = On)
# Enables or disables the CSV data header info (1 line)
# dd/MM/yyyy HH:mm:ss;kWh;kW
# This is usefull for manual data upload to pvoutput.org
# If CSV_ExtendedHeader is enabled, CSV_Header is also enabled
CSV_Header=$CONFIG_CSV_HEADER
# CSV_SaveZeroPower (default 1 = On)
# When enabled, daily csv files contain all data from 00:00 to 23:55
# This is usefull for manual data upload to pvoutput.org
CSV_SaveZeroPower=$CONFIG_CSV_SAVEZEROPOWER
# CSV_Delimiter (comma/semicolon default semicolon)
CSV_Delimiter=$CONFIG_CSV_DELIMITER
# CSV_Spot_TimeSource (Inverter|Computer default Inverter)
CSV_Spot_TimeSource=$CONFIG_CSV_SPOT_TIMESOURCE
# CSV_Spot_WebboxHeader (Default 0 = Off)
# When enabled, use Webbox style header (DcMs.Watt[A];DcMs.Watt[B]...)
CSV_Spot_WebboxHeader=$CONFIG_CSV_SPOT_WEBBOXHEADER
###########################
### SQL DB Settings ###
###########################
# SQLite
# SQL_Database (Fullpath to SQLite DB)
# Windows: C:\Users\Public\SMAdata\SBFspot.db
# Linux : /home/pi/smadata/SBFspot.db
#SQL_Database=/home/pi/smadata/SBFspot.db
# MySQL
SQL_Database=$CONFIG_SQL_DATABASE
SQL_Hostname=$CONFIG_SQL_HOSTNAME
SQL_Port=$CONFIG_SQL_PORT
SQL_Username=$CONFIG_SQL_USERNAME
SQL_Password=$CONFIG_SQL_PASSWORD
#########################
### MQTT Settings ###
#########################
MQTT_Publisher=$CONFIG_MQTT_PUBLISHER
MQTT_Host=$CONFIG_MQTT_HOST
MQTT_Port=$CONFIG_MQTT_PORT
MQTT_Username=$CONFIG_MQTT_USERNAME
MQTT_Password=$CONFIG_MQTT_PASSWORD
MQTT_Topic=$CONFIG_MQTT_TOPIC
MQTT_ItemFormat=$CONFIG_MQTT_ITEMFORMAT
MQTT_ItemDelimiter=$CONFIG_MQTT_ITEMDELIMITER
MQTT_PublisherArgs=$CONFIG_MQTT_PUBLISHERARGS
MQTT_Data=$CONFIG_MQTT_DATA
EOL
#cat $1
cat > $CFG_PATH_UPLOAD <<EOL
################################################################################
# SBFspotUpload.cfg - Configuration file for SBFspotUploadService/Daemon
# (c)2012-2014, SBF (https://sbfspot.codeplex.com)
#
# DISCLAIMER:
# A user of SBFspotUploadService/Daemon software acknowledges that he or she is
# receiving this software on an "as is" basis and the user is not relying on
# the accuracy or functionality of the software for any purpose. The user
# further acknowledges that any use of this software will be at his own risk
# and the copyright owner accepts no responsibility whatsoever arising from
# the use or application of the software.
#
################################################################################
################################
### Log Settings ###
################################
# Windows: C:\Users\Public\SMAdata\Logs
# Linux : /home/pi/smadata/logs
#LogDir=C:\Users\Public\SMAdata\Logs
LogDir=$CONFIG_LOGDIR
#LogLevel=debug|info|warning|error (default info)
LogLevel=$CONFIG_LOGLEVEL
################################
### PVoutput Upload Settings ###
################################
#PVoutput_SID
#Map inverters to PVoutput System ID's
#PVoutput_SID=SerialNmbrInverter_1:PVoutput_System_ID_1,SerialNmbrInverter_2:PVoutput_System_ID_2
#e.g. PVoutput_SID=200212345:4321
PVoutput_SID=$CONFIG_PVOUTPUT_SID
#PVoutput_Key
#Sets PVoutput API Key
PVoutput_Key=$CONFIG_PVOUTPUT_KEY
################################
### SQL DB Settings ###
################################
# SQL_Database (Fullpath to SQLite DB)
# Windows: C:\Users\Public\SMAdata\SBFspot.db
# Linux : /home/pi/smadata/SBFspot.db
#SQL_Database=C:\Users\Public\SMAdata\SBFspot.db
#SQL_Database=/home/pi/smadata/SBFspot.db
# Reserved for MySQL
SQL_Database=$CONFIG_SQL_DATABASE
SQL_Hostname=$CONFIG_SQL_HOSTNAME
SQL_Username=$CONFIG_SQL_USERNAME
SQL_Password=$CONFIG_SQL_PASSWORD
EOL
#cat $CFG_PATH_UPLOAD
# create folders
mkdir -p $CONFIG_OUTPUTPATH
mkdir -p $CONFIG_LOGDIR

View file

@ -0,0 +1,141 @@
#!/bin/bash
# Copyright 2016-2018 Stuart Shelton
# Distributed under the terms of the GNU General Public License v2
declare verbose="${VERBOSE:-1}"
declare trace="${TRACE:-0}"
# Edit the list below to specify those services which should be restarted on
# failure, rather than only generating an alert:
declare -a rc_monitor_restart=(
apache
dovecot
mysql
opendkim
postfix
postgres
)
einfo="echo"
ewarn="echo"
eerror="echo"
ebegin="echo"
eend=":"
if [[ -r /lib/rc/sh/functions.sh ]]; then
# shellcheck disable=SC1091
source /lib/rc/sh/functions.sh
# Sets 'RC_GOT_FUNCTIONS="yes"'
einfo="einfo"
ewarn="einfo"
eerror="eerror"
ebegin="ebegin"
eend="eend"
fi
# We don't warn on unbound variables before now as stock OpenRC functions.sh
# has two such cases in it, as of sys-apps/openrc-0.19.1 :(
#
set -u
if grep -Eq -- ' -(q|-quiet) ' <<<" ${*:-} "; then
EINFO_QUIET=yes
fi
if yesno "${EINFO_QUIET:-}"; then
verbose=0
fi
quiet=""
(( verbose )) && quiet="--quiet"
if (( EUID )); then
if [[ -n "${RC_GOT_FUNCTIONS:-}" ]]; then
eerror "Please execute $( basename "${0:-}" ) as UID 0"
else
echo >&2 "FATAL: Please execute $( basename "${0:-}" ) as UID 0"
fi
exit 1
fi
if grep -Eq -- ' -(h|-help) ' <<<" ${*:-} "; then
echo "Usage: $( basename "${0:-}" ) [--quiet] [-- service_to_restart[,...]]"
exit 0
fi
(( trace )) && set -o xtrace
if grep -Eq -- ' -- ' <<<" ${*:-} "; then
while [[ -n "${1:-}" ]]; do
case "${1}" in
--)
shift
break
;;
*)
shift
;;
esac
done
if [[ -n "${*:-}" && -n "${*// }" ]]; then
if grep -q -- ' default ' <<<" ${*} "; then
for item in "${@}"; do
[[ -n "${item:-}" && "${item:-}" != "default" ]] &&
! grep -q -- " ${item} " <<<" ${rc_monitor_restart[*]:-} " &&
rc_monitor_restart+=( "${item}" )
done
else
rc_monitor_restart=( "${@}" )
fi
if (( verbose )); then
${einfo} "Services which will be restarted if crashed:"
${einfo} "$( sed 's/ /, /g' <<<"${rc_monitor_restart[*]:-}" )"
fi
fi
fi
(( verbose )) && ${ebegin} "Checking for crashed services"
declare -i rc=0
declare -i monitored=0
for svc in $( rc-status --crashed --all ); do
monitored=0
for chk in "${rc_monitor_restart[@]:-}"; do
if [[ -n "${chk:-}" && "${chk}" == "${svc:-}" ]]; then
monitored=1
# We use --nodeps as a restart could stop critical services that
# depend on us...
declare -i result=0
if rc-service "${svc}" -- ${quiet:-} --nodeps restart; then
(( 0 == rc )) && rc=1
else
${eerror} "Service ${svc} failed to restart: ${?}"
${ewarn} "Attempting to stop then start service ${svc} ..."
rc-service "${svc}" -- ${quiet:-} --nodeps stop
rc-service "${svc}" -- ${quiet:-} --nodeps start
result=${?}
if ! (( result )); then
(( 0 == rc )) && rc=1
else
rc=2
${eerror} "Service ${svc} failed to stop/start: ${result}"
fi
fi
continue 2
fi
done
if (( monitored )); then
${ewarn} "Service '${svc:-}' crashed but requires a manual restart"
rc=2
else
${ewarn} "Service '${svc:-}' crashed but is not monitored and so will not be restarted"
fi
done
(( verbose )) && ${eend} $(( 2 == rc )) "Crashed services are present which could not be restarted"
(( trace )) && set +o xtrace
exit $(( 0 != rc ))

View file

@ -0,0 +1,4 @@
configuration:
message:
name: Message
description: Monitoring SMA Bluetooth inverters with SBFspot.