2022.9.1 (#34)

* Update en.yaml

Update options

* Prettified Code!

* Update en.yaml

* Prettified Code!

* Update en.yaml

* Update Dockerfile

curl dev version -> rc3
chmod changed to folders instead of files
taillog auto logs to dev stdout.. it is just a timestamp now

* Update build.yaml

codenotary..

* Update taillog.sh

SBFspot 3.9.6 logging changes
no files anymore. so just timestamp.

* Update genBluetoothConfig.sh

converted to bashio

* Update genEthernetConfig.sh

converted to bashio

* Create genSenBlue

Created for Bluetooth inverter sensors

* Create genSenEth

created for Ethernet inverter sensors
makes set config

* Create mqttSensorConfig

making sensors..

* Create purgeSen

purge sensors...

* Create nanorc

nano defaults.

* Update finish

exit code changes

* Update run

sensors and bashio changes

* Update config.yaml

defaulted most options in bashio

* Update en.yaml

spaces...

* Update en.yaml

* Update en.yaml

* Update en.yaml

* Prettified Code!

* Update config.yaml

* Update DOCS.md

updating for changes and making pretty

* Update README.md

* Prettified Code!

* Add files via upload

* Update README.md

* Update DOCS.md

* Update en.yaml

* Prettified Code!

* Update README.md

* Prettified Code!

* Update DOCS.md

* Update en.yaml

* Prettified Code!

* Update README.md

* Update en.yaml

* Prettified Code!

* Update DOCS.md

* Update en.yaml

* Prettified Code!

* Update README.md

* Update .mdlrc

* Prettified Code!

* Update DOCS.md

* Update CHANGELOG.md

2022.9.1

* Update README.md

* Update DOCS.md

* Update README.md

* Update README.md

* Update DOCS.md

* Delete UI options.PNG

renaming

* Delete mqqt Capture.PNG

renaming

* Add files via upload

* Update README.md

* Update README.md

* Delete MQTTcapture.PNG

* Add files via upload

* Update README.md

* Update DOCS.md

* Update CHANGELOG.md

* Update README.md

* Update DOCS.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: habuild <habuild@users.noreply.github.com>
This commit is contained in:
habuild 2022-09-06 20:28:32 +10:00 committed by GitHub
parent 6ff0344d61
commit 1688059878
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 2562 additions and 282 deletions

BIN
.images/UIoptions.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
.images/mqttcap.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

2
.mdlrc
View file

@ -1,2 +1,2 @@
# Exclude line length
rules "~MD013", "~MD026", "~MD022"
rules "~MD013", "~MD026", "~MD022", "~MD033", "~MD034"

View file

@ -2,6 +2,50 @@
# ![Version](https://img.shields.io/badge/dynamic/yaml?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fhassio-addons%2Fmain%2Fhaos-sbfspot%2Fconfig.yaml)
- Bump to SBFspot 3.9.6
- BREAKING CHANGES
- Major overhaul of options
- Most options have defaults set that will be used when options left blank
- Secrets template provided in the readme!
<br></br>
- MQTT user and pass have moved locations in options
- MQTT Publisher args option has been disabled
<br></br>
- AUTOGEN SENSORS
- List of upto 39 sensors available
- New Option create or purge sensors (defaults to No)
- Some Sensors start disabled in the MQTT integration
- (They can be enabled in the MQTT integration)
- Disabled sensors are not automatically deleted by the MQTT integration (Purge will get them)
- Sensors can now be created and purged via the Addon and HA MQTT integration
- Backup and disable/remove existing yaml sensors to avoid naming conflicts
- MQTT_Data list can be used to create desired Sensors.
<br></br>
- custom timestamp can be set for InvTime SunRise and SunSet
- Timestamp sensor can not use custom timestamp
- (can be changed by value_template in a lovelace card)
<br></br>
- Logging to *.txt file is being removed from SBFspot 3.9.6 onwards
- option for logging dir removed to accommodate this change
<br></br>
- Cleaned up readme...
- updated translations to reflect options changes
- bump curl dev dependancy
## ![Release][release-shield-2022-8-4]
[release-shield-2022-8-4]: https://img.shields.io/badge/version-2022.8.4-blue.svg
- Created translations to give more detail to UI options.
- MQTT_Enable option has been removed.
- It has to be manually removed via yaml options to stop supervisor log warning about it.

View file

@ -1,3 +1,5 @@
---
# SBFspot addon for HAOS
![Version](https://img.shields.io/badge/dynamic/yaml?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fhassio-addons%2Fmain%2Fhaos-sbfspot%2Fconfig.yaml)
@ -10,7 +12,7 @@
[![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)
This [home assistant](https://www.home-assistant.io/getting-started/) add-on provides a wrapper for the **Bluetooth** version of [SBFspot 3.9.5](https://github.com/SBFspot/SBFspot/releases/latest).
This [home assistant](https://www.home-assistant.io/getting-started/) add-on provides a wrapper for the **Bluetooth** version of [SBFspot 3.9.6](https://github.com/SBFspot/SBFspot/releases/latest).
This add-on runs a crontab service for SBFspot and SPFspotUploader at 5 minutely daytime interval.
@ -24,44 +26,180 @@ This add-on runs a crontab service for SBFspot and SPFspotUploader at 5 minutely
## Installation
---
### Options and Secrets
If you want to template your options with secrets, the below template can be used.
These names auto default so you shouldn't need to confirm(save) any options on installation
It should all just default when starting the addon.
```
##template for secrets.yaml
## a restart might be required after Saving your secrets file
BTAddress: "" ## Inverter BT mac
SBFpassword: "" ## Inverter password
LocalBTAddress: "" # host BT mac - can be empty
SBFplantname: ""
mariadb_pw: ""
mqtt_user: ""
mqtt_pass: ""
home_lat: ""
home_long: ""
Timezone: ""
### IF YOU WANT TO SKIP PVoutput
pvoSID: "0123456789:12345" ### will default to fake if left empty
pvoAPIkey: "fake9364fake4545afke834fake" ### will default to fake if left empty
```
The above options are the only required options if you want to fill out the options manually.
### The rest of the options default to standard HAOS server addresses and SBFspot defaults
<details><summary> OPTIONS Image </summary>
<p>
![screenshot](https://raw.githubusercontent.com/habuild/hassio-addons/main/.images/UIoptions.PNG)
</p>
</details>
<br></br>
## MQTT
### 2022.9.1+
#### Add MQTT mqtt user and password to options.
The other options default automatically if blank.
If you need to change the broker address, you can stil use the options.
#### HA Sensor Generation
<details><summary>MQTT Sensor list</summary>
<p>
Description available in the SBFspot config file.
[Default SBFspot CFG](https://raw.githubusercontent.com/habuild/hassio-addons/2022.9.1/haos-sbfspot/rootfs/usr/bin/sbfspot/SBFspot.default.cfg)
*
Default list of Sensors for MQTT_Data
```
Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvSwVer,InvClass,InvType,InvTemperature,OperTm,FeedTm,EToday,ETotal,GridFreq,PACTot,PAC1,UAC1,IAC1,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,BTSignal
```
*
Current available list of sensors (There are some new ones, which are not available yet)
```
Timestamp,InvTime,SunRise,SunSet,InvSerial,InvName,InvClass,InvType,InvSwVer,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,OperTm,FeedTm,PACTot,PAC1,PAC2,PAC3,UAC1,UAC2,UAC3,IAC1,IAC2,IAC3,GridFreq,BTSignal,BatTmpVal,BatVol,BatAmp,BatChaStt
```
*
Sensors to be added at a later date
```
PrgVersion,InvWakeupTm,InvSleepTm,MeteringWOut,MeteringWIn,MeteringWTot
```
[MASTER SBFspot CFG](https://raw.githubusercontent.com/SBFspot/SBFspot/master/SBFspot/SBFspot.cfg)
</p>
</details>
<details><summary>MQTT Image</summary>
<p>
![screenshot](https://raw.githubusercontent.com/habuild/hassio-addons/main/.images/mqttcap.PNG)
</p>
</details>
It is advised to **backup and/or disable existing yaml sensors** to avoid naming conflicts.
#### Autogen Sensors - No, Create, Purge, options
<details><summary><b>No</b> sensors. HAOS-SBFspot will run without generating sensors. It will use yaml or mqtt sensors. </summary>
<p>
</p>
</details>
<details><summary><b>Create</b> sensors. HAOS-SBFspot will automatically create sensors in the MQTT Integration. </summary>
<p>
[MQTT Integration](https://www.home-assistant.io/integrations/mqtt)
It is advised to **backup and/or disable existing yaml sensors** to avoid naming conflicts.
- This option will create topics using your plantname and inverter serial number
- homeassistant/sensor/sbfspot_{*Your Plantname*}/sbf_spot{*your inv serial*}{*SensorType*}/config
- homeassistant/sbfspot_{Your Plantname}/sbf_spot{Your Inv Serial} is the state_topic
</p>
</details>
<details><summary><b>Purge</b> sensors. HAOS-SBFspot will send empty topics to your broker address to clear Retained topics. </summary>
<p>
- This will fail if you change topics between creating and purging sensors.
- You can use MQTT explorer or similar MQTT tool to manually remove the topics if this occurs.
</p>
</details>
<details><summary> Earlier versions and yaml mqtt sensors </summary>
<p>
### Prior to 2022.9.1
[haos-sbfspot_sensors.yaml](https://github.com/habuild/hassio-addons/blob/main/.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.
**MQTT options argument** [configuration options](https://github.com/habuild/hassio-addons/blob/main/.images/Example_Config.yaml) The MQTT Username, and Password need to be hardcoded into the **MQTT_PublisherArgs:** The **{host}** **{topic}** and **{{message}}** will be picked up from options.
**MQTT_PublisherArgs:** **'-h {host} -u Your_MQTT_Username -P Your_MQTT_password -t {topic} -m "{{message}}" -d -r'**
<i> Publisher arguments has been removed to allow for sensors </i>
**-d** is for MQTT debug in log. Which is helpful for confirming the MQTT messages are actually being sent.
**-r** is to retain messages. it is advised against using retain flag
</p>
</details>
<br></br>
## MariaDB
### Initial database creation.
Download and import either [No Drop DB create](https://github.com/habuild/hassio-addons/blob/main/.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/hassio-addons/main/.images/MariaDB%20setup.PNG)
### MQTT
<br></br>
[haos-sbfspot_sensors.yaml](https://github.com/habuild/hassio-addons/blob/main/.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.
## Container Data paths
**MQTT options argument** [configuration options](https://github.com/habuild/hassio-addons/blob/main/.images/Example_Config.yaml). The MQTT Username, and Password need to be hardcoded into the **MQTT_PublisherArgs:** The **{host}** **{topic}** and **{{message}}** will be picked up from options.
In HAOS (home assistant operating system) the /data/ path arrives at `/mnt/data/supervisor/addons/data/{slug_haos-sbfspot}` on the host.
**MQTT_PublisherArgs:** **'-h {host} -u Your_MQTT_Username -P Your_MQTT_password -t {topic} -m "{{message}}" -d -r'**
In docker/supervisor the /data/ path arrives at `/usr/share/hassio/addons/data/{slug_haos-sbfspot}` on the host.
**-d** is for MQTT debug in log. Which is helpful for confirming the MQTT messages are actually being sent.
**-r** is to retain messages. it is advised against using retain flag
### Example Configuration Options.
can be copy/pasted as [Example Config](https://github.com/habuild/hassio-addons/blob/main/haos-sbfspot/.images/Example_Config.yaml) or entered via UI
![Example Options](https://raw.githubusercontent.com/habuild/hassio-addons/main/.images/Example_config_png.PNG)
### Data paths
In HAOS (home assistant operating system) the /data/ path arrives at /mnt/data/supervisor/addons/data/{slug}\_haos-sbfspot on the host.
### Upload logs
Logs delete after 3 days now. You would need SSH with Root host access to find them anyway.
### **Link to haos-sbfspot Documentation**
## **Link to official SBFspot Documentation**
Refer to the [SBFspot Wiki](https://github.com/sbfspot/sbfspot/wiki) for documentation and FAQ about SBFspot.
### **Special thanks to:**
- LauR3y/hassio-addons-addons which this version is cleaned up from.
- The sbfspot team for SPFspot.
![Supports aarch64 Architecture][aarch64-shield]

View file

@ -18,7 +18,7 @@ RUN apk update && apk add --no-cache \
bluez=5.65-r0 \
bluez-dev=5.65-r0 \
boost-dev=1.78.0-r1 \
curl-dev=7.83.1-r2 \
curl-dev=7.83.1-r3 \
git=2.36.2-r0 \
g++=11.2.1_git20220219-r2 \
make=4.3-r0 \
@ -82,8 +82,8 @@ COPY --from=builder-base /tmp/SBFspot/TagList* /usr/bin/sbfspot/
COPY rootfs /
RUN chmod a+x /etc/services.d/sbfspot/run /etc/services.d/sbfspot/finish /usr/bin/sbfspot/taillog.sh /usr/bin/sbfspot/generateConfig.sh /usr/bin/sbfspot/genBluetoothConfig.sh /usr/bin/sbfspot/genEthernetConfig.sh /usr/bin/sbfspot/SBFspot /usr/bin/sbfspot/SBFspotUploadDaemon /usr/bin/sbfspot/SBFspot.default.cfg /usr/bin/sbfspot/SBFspotUpload.default.cfg
RUN chmod a+x /etc/services.d/sbfspot/** /usr/bin/sbfspot/**
# --- install cron ---
# set shell
RUN echo 'SHELL=/bin/bash' > /etc/crontabs/root
@ -95,8 +95,8 @@ RUN echo '*/5 6-22 * * * /usr/bin/sbfspot/SBFspot -v -ad1 -am0 -ae0 -mqtt > /
RUN echo '55 05 * * * /usr/bin/sbfspot/SBFspot -v -sp0 -ad0 -am1 -ae1 -finq > /dev/stdout' >> /etc/crontabs/root
# start SBFspotUpload 1 min after boot
RUN echo '@reboot sleep 60 && /usr/bin/sbfspot/SBFspotUploadDaemon -c /usr/bin/sbfspot/SBFspotUpload.cfg > /dev/stdout' >> /etc/crontabs/root
# Log SBFspotUpload to HA logging window
RUN echo '*/5 6-22 * * * /usr/bin/sbfspot/taillog.sh > /dev/stdout' >> /etc/crontabs/root
# Log SBFspotUpload to HA logging window defunct now in version 3.9.6+ sbfspot, using it for the timed message
RUN echo '*/5 6-22 * * * /usr/bin/sbfspot/taillog.sh' >> /etc/crontabs/root
# Labels
LABEL \

View file

@ -1,3 +1,5 @@
---
# SBFspot addon for HAOS
![Version](https://img.shields.io/badge/dynamic/yaml?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Fhabuild%2Fhassio-addons%2Fmain%2Fhaos-sbfspot%2Fconfig.yaml)
@ -10,7 +12,7 @@
[![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)
This [home assistant](https://www.home-assistant.io/getting-started/) add-on provides a wrapper for the **Bluetooth** version of [SBFspot 3.9.5](https://github.com/SBFspot/SBFspot/releases/latest).
This [home assistant](https://www.home-assistant.io/getting-started/) add-on provides a wrapper for the **Bluetooth** version of [SBFspot 3.9.6](https://github.com/SBFspot/SBFspot/releases/latest).
This add-on runs a crontab service for SBFspot and SPFspotUploader at 5 minutely daytime interval.
@ -24,44 +26,180 @@ This add-on runs a crontab service for SBFspot and SPFspotUploader at 5 minutely
## Installation
---
### Options and Secrets
If you want to template your options with secrets, the below template can be used.
These names auto default so you shouldn't need to confirm(save) any options on installation
It should all just default when starting the addon.
```
##template for secrets.yaml
## a restart might be required after Saving your secrets file
BTAddress: "" ## Inverter BT mac
SBFpassword: "" ## Inverter password
LocalBTAddress: "" # host BT mac - can be empty
SBFplantname: ""
mariadb_pw: ""
mqtt_user: ""
mqtt_pass: ""
home_lat: ""
home_long: ""
Timezone: ""
### IF YOU WANT TO SKIP PVoutput
pvoSID: "0123456789:12345" ### will default to fake if left empty
pvoAPIkey: "fake9364fake4545afke834fake" ### will default to fake if left empty
```
The above options are the only required options if you want to fill out the options manually.
### The rest of the options default to standard HAOS server addresses and SBFspot defaults
<details><summary> OPTIONS Image </summary>
<p>
![screenshot](https://raw.githubusercontent.com/habuild/hassio-addons/main/.images/UIoptions.PNG)
</p>
</details>
<br></br>
## MQTT
### 2022.9.1+
#### Add MQTT mqtt user and password to options.
The other options default automatically if blank.
If you need to change the broker address, you can stil use the options.
#### HA Sensor Generation
<details><summary>MQTT Sensor list</summary>
<p>
Description available in the SBFspot config file.
[Default SBFspot CFG](https://raw.githubusercontent.com/habuild/hassio-addons/2022.9.1/haos-sbfspot/rootfs/usr/bin/sbfspot/SBFspot.default.cfg)
*
Default list of Sensors for MQTT_Data
```
Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvSwVer,InvClass,InvType,InvTemperature,OperTm,FeedTm,EToday,ETotal,GridFreq,PACTot,PAC1,UAC1,IAC1,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,BTSignal
```
*
Current available list of sensors (There are some new ones, which are not available yet)
```
Timestamp,InvTime,SunRise,SunSet,InvSerial,InvName,InvClass,InvType,InvSwVer,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,OperTm,FeedTm,PACTot,PAC1,PAC2,PAC3,UAC1,UAC2,UAC3,IAC1,IAC2,IAC3,GridFreq,BTSignal,BatTmpVal,BatVol,BatAmp,BatChaStt
```
*
Sensors to be added at a later date
```
PrgVersion,InvWakeupTm,InvSleepTm,MeteringWOut,MeteringWIn,MeteringWTot
```
[MASTER SBFspot CFG](https://raw.githubusercontent.com/SBFspot/SBFspot/master/SBFspot/SBFspot.cfg)
</p>
</details>
<details><summary>MQTT Image</summary>
<p>
![screenshot](https://raw.githubusercontent.com/habuild/hassio-addons/main/.images/mqttcap.PNG)
</p>
</details>
It is advised to **backup and/or disable existing yaml sensors** to avoid naming conflicts.
#### Autogen Sensors - No, Create, Purge, options
<details><summary><b>No</b> sensors. HAOS-SBFspot will run without generating sensors. It will use yaml or mqtt sensors. </summary>
<p>
</p>
</details>
<details><summary><b>Create</b> sensors. HAOS-SBFspot will automatically create sensors in the MQTT Integration. </summary>
<p>
[MQTT Integration](https://www.home-assistant.io/integrations/mqtt)
It is advised to **backup and/or disable existing yaml sensors** to avoid naming conflicts.
- This option will create topics using your plantname and inverter serial number
- homeassistant/sensor/sbfspot_{*Your Plantname*}/sbf_spot{*your inv serial*}{*SensorType*}/config
- homeassistant/sbfspot_{Your Plantname}/sbf_spot{Your Inv Serial} is the state_topic
</p>
</details>
<details><summary><b>Purge</b> sensors. HAOS-SBFspot will send empty topics to your broker address to clear Retained topics. </summary>
<p>
- This will fail if you change topics between creating and purging sensors.
- You can use MQTT explorer or similar MQTT tool to manually remove the topics if this occurs.
</p>
</details>
<details><summary> Earlier versions and yaml mqtt sensors </summary>
<p>
### Prior to 2022.9.1
[haos-sbfspot_sensors.yaml](https://github.com/habuild/hassio-addons/blob/main/.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.
**MQTT options argument** [configuration options](https://github.com/habuild/hassio-addons/blob/main/.images/Example_Config.yaml) The MQTT Username, and Password need to be hardcoded into the **MQTT_PublisherArgs:** The **{host}** **{topic}** and **{{message}}** will be picked up from options.
**MQTT_PublisherArgs:** **'-h {host} -u Your_MQTT_Username -P Your_MQTT_password -t {topic} -m "{{message}}" -d -r'**
<i> Publisher arguments has been removed to allow for sensors </i>
**-d** is for MQTT debug in log. Which is helpful for confirming the MQTT messages are actually being sent.
**-r** is to retain messages. it is advised against using retain flag
</p>
</details>
<br></br>
## MariaDB
### Initial database creation.
Download and import either [No Drop DB create](https://github.com/habuild/hassio-addons/blob/main/.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/hassio-addons/main/.images/MariaDB%20setup.PNG)
### MQTT
<br></br>
[haos-sbfspot_sensors.yaml](https://github.com/habuild/hassio-addons/blob/main/.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.
## Container Data paths
**MQTT options argument** [configuration options](https://github.com/habuild/hassio-addons/blob/main/.images/Example_Config.yaml). The MQTT Username, and Password need to be hardcoded into the **MQTT_PublisherArgs:** The **{host}** **{topic}** and **{{message}}** will be picked up from options.
In HAOS (home assistant operating system) the /data/ path arrives at `/mnt/data/supervisor/addons/data/{slug_haos-sbfspot}` on the host.
**MQTT_PublisherArgs:** **'-h {host} -u Your_MQTT_Username -P Your_MQTT_password -t {topic} -m "{{message}}" -d -r'**
In docker/supervisor the /data/ path arrives at `/usr/share/hassio/addons/data/{slug_haos-sbfspot}` on the host.
**-d** is for MQTT debug in log. Which is helpful for confirming the MQTT messages are actually being sent.
**-r** is to retain messages. it is advised against using retain flag
### Example Configuration Options.
can be copy/pasted as [Example Config](https://github.com/habuild/hassio-addons/blob/main/haos-sbfspot/.images/Example_Config.yaml) or entered via UI
![Example Options](https://raw.githubusercontent.com/habuild/hassio-addons/main/.images/Example_config_png.PNG)
### Data paths
In HAOS (home assistant operating system) the /data/ path arrives at /mnt/data/supervisor/addons/data/{slug}\_haos-sbfspot on the host.
### Upload logs
Logs delete after 3 days now. You would need SSH with Root host access to find them anyway.
### **Link to haos-sbfspot Documentation**
## **Link to official SBFspot Documentation**
Refer to the [SBFspot Wiki](https://github.com/sbfspot/sbfspot/wiki) for documentation and FAQ about SBFspot.
### **Special thanks to:**
- LauR3y/hassio-addons-addons which this version is cleaned up from.
- The sbfspot team for SPFspot.
![Supports aarch64 Architecture][aarch64-shield]

View file

@ -1,16 +1,19 @@
---
name: HAOS-SBFspot
version: 2022.8.4
version: 2022.9.1
slug: haos-sbfspot
description: Manage SBFspot with a simple interface
url: "https://github.com/habuild/hassio-addons/tree/main/haos-sbfspot"
stage: experimental
image: "ghcr.io/habuild/{arch}-addon-haos-sbfspot"
arch:
- armhf
- armv7
- aarch64
- amd64
init: false
host_network: true
host_dbus: true
homeassistant_api: true
panel_icon: mdi:solar-power-variant
services:
@ -18,76 +21,48 @@ services:
- mqtt:want
options:
Connection_Type: "Bluetooth"
BTAddress: ""
Password: "0000"
LocalBTAddress: "00:00:00:00:00:00"
Sensors_HA: No
BTAddress: "!secret BTAddress"
Password: "!secret SBFpassword"
LocalBTAddress: "!secret LocalBTAddress"
IP_Address: "255.255.255.255"
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: "SBFspot"
SQL_Hostname: core-mariadb
SQL_Port: "3306"
SQL_Username: "sbfspot"
SQL_Password: ""
MQTT_Publisher: /usr/bin/mosquitto_pub
MQTT_Host: core-mosquitto
MQTT_Port: "1883"
Plantname: "!secret SBFplantname"
Latitude: "!secret home_lat"
Longitude: "!secret home_long"
Timezone: "!secret Timezone"
DateTimeFormat: "'%H:%M:%S %d-%m-%y'"
SQL_Password: "!secret mariadb_pw"
MQTT_User: "!secret mqtt_user"
MQTT_Pass: "!secret mqtt_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,GridFreq,PACTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2
PVoutput_SID: "0123456789:12345"
PVoutput_Key: "fake9364fake4545fake834fake"
LogDir: /data/sbfspot/log/
Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvSwVer,InvClass,InvType,InvTemperature,OperTm,FeedTm,EToday,ETotal,GridFreq,PACTot,PAC1,UAC1,IAC1,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,BTSignal
PVoutput_SID: "!secret pvoSID"
PVoutput_Key: "!secret pvoAPIkey"
LogLevel: info
schema:
Connection_Type: list(Bluetooth|Ethernet)?
Sensors_HA: list(No||Create||Purge|)?
BTAddress: "str"
Password: "str"
LocalBTAddress: "str"
IP_Address: "str"
Password: "password"
LocalBTAddress: "str?"
IP_Address: "str?"
Plantname: "str"
MIS_Enabled: "int?"
OutputPath: "str?"
OutputPathEvents: "str?"
Latitude: "float"
Longitude: "float"
Timezone: "str"
DateTimeFormat: "str"
DateFormat: "str"
DecimalPoint: "str"
TimeFormat: "str"
Latitude: "str?"
Longitude: "str?"
Timezone: "str?"
DateTimeFormat: "str?"
DateFormat: "str?"
DecimalPoint: "str?"
TimeFormat: "str?"
SynchTime: "int?"
SynchTimeLow: "int?"
SynchTimeHigh: "int?"
SunRSOffset: "int?"
Locale: "str"
Locale: "str?"
CalculateMissingSpotValues: "int?"
BTConnectRetries: "int?"
CSV_Export: "int?"
@ -101,19 +76,17 @@ schema:
SQL_Hostname: "str?"
SQL_Port: "str?"
SQL_Username: "str?"
SQL_Password: "str?"
SQL_Password: "password?"
MQTT_Publisher: "str?"
MQTT_Host: "str"
MQTT_Port: "str"
MQTT_Host: "str?"
MQTT_Port: "str?"
MQTT_User: "str"
MQTT_Pass: "password"
MQTT_Topic: "str"
MQTT_ItemFormat: "str"
MQTT_ItemDelimiter: str
MQTT_PublisherArgs: str
MQTT_ItemFormat: "str?"
MQTT_ItemDelimiter: str?
MQTT_PublisherArgs: str?
MQTT_Data: "str"
PVoutput_SID: "str"
PVoutput_Key: "str"
LogDir: "str?"
LogLevel: "str"
host_network: true
host_dbus: true
image: "ghcr.io/habuild/{arch}-addon-haos-sbfspot"
PVoutput_SID: "password?"
PVoutput_Key: "password?"
LogLevel: list(debug|info||warning||error)?

View file

@ -0,0 +1,295 @@
## Sample initialization file for GNU nano.
##
## For the options that take parameters, the default value is shown.
## Other options are unset by default. To make sure that an option
## is disabled, you can use "unset <option>".
##
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
## stop at word ends instead of at beginnings.
# set afterends
## When soft line wrapping is enabled, make it wrap lines at blanks
## (tabs and spaces) instead of always at the edge of the screen.
# set atblanks
## Automatically indent a newly created line to the same number of
## tabs and/or spaces as the preceding line -- or as the next line
## if the preceding line is the beginning of a paragraph.
# set autoindent
## Back up files to the current filename plus a tilde.
# set backup
## The directory to put unique backup files in.
# set backupdir ""
## Use bold text instead of reverse video text.
# set boldtext
## Treat any line with leading whitespace as the beginning of a paragraph.
# set bookstyle
## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters. Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
# set brackets ""')>]}"
## Automatically hard-wrap the current line when it becomes overlong.
# set breaklonglines
## Do case-sensitive searches by default.
# set casesensitive
## Constantly display the cursor position in the status bar. Note that
## this overrides "quickblank".
# set constantshow
## Use cut-from-cursor-to-end-of-line by default.
# set cutfromcursor
## Do not use the line below the title bar, leaving it entirely blank.
# set emptyline
## Set the target width for automatic hard-wrapping and for justifying
## paragraphs. If the specified value is 0 or less, the wrapping point
## will be the terminal's width minus this number.
# set fill -8
## Remember the used search/replace strings for the next session.
set historylog
## Display a "scrollbar" on the righthand side of the edit window.
set indicator
## Scroll the buffer contents per half-screen instead of per line.
# set jumpyscrolling
## Display line numbers to the left (and any anchors in the margin).
set linenumbers
## Enable vim-style lock-files. This is just to let a vim user know you
## are editing a file [s]he is trying to edit and vice versa. There are
## no plans to implement vim-style undo state in these files.
set locking
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
# set matchbrackets "(<[{)>]}"
## Enable mouse support, if available for your system. When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts. The mouse will work in the X
## Window System, and on the console when gpm is running.
# set mouse
## Switch on multiple file buffers (inserting a file will put it into
## a separate buffer).
# set multibuffer
## Don't convert files from DOS/Mac format.
# set noconvert
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't automatically add a newline when a file does not end with one.
# set nonewlines
## Set operating directory. nano will not read or write files outside
## this directory and its subdirectories. Also, the current directory
## is changed to here, so any files are inserted from this dir. A blank
## string means the operating-directory feature is turned off.
# set operatingdir ""
## Remember the cursor position in each file for the next editing session.
# set positionlog
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
## The characters treated as closing punctuation when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
# set punct "!.?"
## Do quick status-bar blanking. Status-bar messages will disappear after
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
# set quickblank
## The regular expression that matches quoting characters in email
## or line-comment introducers in source code. The default is:
# set quotestr "^([ ]*([!#%:;>|}]|//))+"
## Try to work around a mismatching terminfo terminal description.
# set rawsequences
## Fix Backspace/Delete confusion problem.
# set rebinddelete
## Do regular-expression searches by default.
## Regular expressions are of the extended type (ERE).
# set regexp
## Save a changed buffer automatically on exit; don't prompt.
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and show
## the cursor in the help viewer; useful for people who use a braille
## display and people with poor vision.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the
## cursor is already at that position, it will jump to the true
## beginning of the line.
# set smarthome
## Spread overlong lines over multiple screen lines.
set softwrap
## Use this spelling checker instead of the internal one. This option
## does not have a default value.
# set speller "aspell -x -c"
## Use the end of the title bar for some state flags: I = auto-indenting,
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
set stateflags
## Allow nano to be suspended (with ^Z by default).
set suspendable
## (The old form of this option, 'set suspend', is deprecated.)
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
## Convert typed tabs to spaces.
# set tabstospaces
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
## The two single-column characters used to display the first characters
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
## The default when in a UTF-8 locale:
# set whitespace "»·"
## The default otherwise:
# set whitespace ">."
## Detect word boundaries differently by treating punctuation
## characters as parts of words.
# set wordbounds
## The characters (besides alphanumeric ones) that should be considered
## as parts of words. This option does not have a default value. When
## set, it overrides option 'set wordbounds'.
# set wordchars "<_>."
## Let an unmodified Backspace or Delete erase the marked region (instead
## of a single character, and without affecting the cutbuffer).
# set zap
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor bold,lightwhite,blue
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set scrollercolor cyan
# set numbercolor cyan
set keycolor cyan
set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor bold,lightwhite,magenta
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta
# set keycolor lightmagenta
# set functioncolor magenta
## === Syntax coloring ===
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
## To include most of the existing syntax definitions, you can do:
include "/usr/share/nano/*.nanorc"
## Or you can select just the ones you need. For example:
# include "/usr/share/nano/html.nanorc"
# include "/usr/share/nano/python.nanorc"
include "/usr/share/nano/sh.nanorc"
## In /usr/share/nano/extra/ you can find some syntaxes that are
## specific for certain distros or for some less common languages.
## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
# extendsyntax python tabgives " "
## If <Tab> should always produce an actual TAB when editing a Makefile:
# extendsyntax makefile tabgives " "
## === Key bindings ===
## For all details, see 'man nanorc', section REBINDING KEYS.
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
## the ASCII character for backspace, so it is bound by default to the
## backspace function. The <Backspace> key itself produces a different
## keycode, which is hard-bound to the backspace function. So, if you
## normally use <Backspace> for backspacing and not ^H, you can make
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H chopwordleft main
## If you would like nano to have keybindings that are more "usual",
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
## then uncomment these:
#bind ^Q exit all
#bind ^S savefile main
#bind ^W writeout main
#bind ^O insert main
#bind ^H help all
#bind ^H exit help
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind ^D findprevious all
#bind ^R replace main
#bind M-X flipnewbuffer all
#bind ^X cut all
#bind ^C copy main
#bind ^V paste all
#bind ^P location main
#bind ^A mark main
#unbind ^K main
#unbind ^U all
#unbind ^N main
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^Y speller main
#bind M-U undo main
#bind M-R redo main
#bind ^U undo main
#bind ^E redo main
#set multibuffer

View file

@ -4,7 +4,7 @@
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
CONFIG_PATH=/data/options.json
#CFG_PATH=/usr/bin/sbfspot/SBFspot.cfg
#CFG_UPLOAD_PATH=/usr/bin/sbfspot/SBFspotUpload.cfg
@ -29,6 +29,27 @@ bashio::log.info ${__BASHIO_COLORS_BLUE} "${message:="Hello World..."}"
bashio::log.info
#set -x
var="$(jq --raw-output '.Sensors_HA' $CONFIG_PATH)"
if bashio::var.equals "${var}" "No"; then
bashio::log.yellow '| SKIPPING MQTT SENSOR CREATION |'
elif bashio::var.equals "${var}" "Create"; then
bashio::log.magenta '| INITIALISE MQTT SENSOR CREATION |'
/usr/bin/sbfspot/mqttSensorConfig
elif bashio::var.equals "$var" "Purge"; then
bashio::log.red '| PURGING SENSORS FROM MQTT |'
bashio::log.red '| CONFIRM REMOVAL IN |'
bashio::log.red '| HA MQTT INTEGRATION |'
bashio::log.red '| MQTT BROKER RETAINED MSGS |'
bashio::log.red '| STATISTICS |'
/usr/bin/sbfspot/purgeSen
else
bashio::log.cyan '| No One knows how you got here |'
bashio::log.cyan '| check your option selection |'
fi
value=$(bashio::config 'Connection_Type')
if bashio::var.equals "${value}" "Bluetooth"; then
/usr/bin/sbfspot/genBluetoothConfig.sh /usr/bin/sbfspot/SBFspot.cfg /usr/bin/sbfspot/SBFspotUpload.cfg
@ -58,9 +79,7 @@ else
bashio::log.info ${__BASHIO_COLORS_RED} "Setup failed to create Configs"
bashio::log.info ${__BASHIO_COLORS_RED} ================================
fi
set +x
# ---- RUN ----
message=$(echo "[Starting SBFspotUpload]")
bashio::log.info ${__BASHIO_COLORS_MAGENTA} "${message:=""}"
@ -73,4 +92,4 @@ ln -sf /usr/bin/sbfspot/SBFspotUpload.cfg /SBFspotUpload.cfg
# cron
message=$(echo "[Starting cron in foreground]")
bashio::log.info "${message:=""}"
exec /usr/sbin/crond -f
exec /usr/sbin/crond -f

View file

@ -1,57 +1,57 @@
#!/usr/bin/with-contenv bashio
# export CFG_PATH
# export CFG_PATH_UPLOAD
CFG_PATH=$1
CFG_PATH_UPLOAD=$2
CONFIG_PATH=/data/options.json
CFG_PATH="${1}"
CFG_PATH_UPLOAD="${2}"
#CONFIG_PATH=/data/options.json
# CONFIG_CONNECTION_TYPE="$(jq --raw-output '.Connection_Type' $CONFIG_PATH)"
CONFIG_BTADDRESS="$(jq --raw-output '.BTAddress' $CONFIG_PATH)"
CONFIG_LOCALBTADDRESS="$(jq --raw-output '.LocalBTAddress' $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_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)"
# CONFIG_CONNECTION_TYPE="$(bashio::config 'Connection_Type')"
CONFIG_BTADDRESS="$(bashio::config 'BTAddress' '!secret BTAdress')"
CONFIG_LOCALBTADDRESS="$(bashio::config 'LocalBTAddress' '!secret LocalBTAddress')"
CONFIG_PASSWORD="$(bashio::config 'Password' '!secret SBFpassword')"
CONFIG_MSI_ENABLED="$(bashio::config 'MIS_Enabled' '0')"
CONFIG_PLANTNAME="$(bashio::config 'Plantname')"
CONFIG_OUTPUTPATH="$(bashio::config 'OutputPath' '/data/sbfspot/%Y')"
CONFIG_OUTPUTPATHEVENTS="$(bashio::config 'OutputPathEvents' '/data/sbfspot/%Y/events')"
CONFIG_LATITUDE="$(bashio::config 'Latitude' '!secret home_lat')"
CONFIG_LONGITUDE="$(bashio::config 'Longitude' '!secret home_long')"
CONFIG_CALCULATEMISSINGSPOTVALUES="$(bashio::config 'CalculateMissingSpotValues' '1')"
# CONFIG_DATETIMEFORMAT="$(bashio::config 'DateTimeFormat' '%Y-%m-%d%H:%M:%S%z')"
CONFIG_DATEFORMAT="$(bashio::config 'DateFormat' '%d/%m/%Y')"
CONFIG_DECIMALPOINT="$(bashio::config 'DecimalPoint' 'comma')"
CONFIG_TIMEFORMAT="$(bashio::config 'TimeFormat' '%H:%M:%S%')"
CONFIG_SYNCHTIME="$(bashio::config 'SynchTime' '0')"
CONFIG_SYNCHTIMELOW="$(bashio::config 'SynchTimeLow' '1')"
CONFIG_SYNCHTIMEHIGH="$(bashio::config 'SynchTimeHigh' '3600')"
CONFIG_SUNRSOFFSET="$(bashio::config 'SunRSOffset' '900')"
CONFIG_LOCALE="$(bashio::config 'Locale' 'en-US')"
CONFIG_TIMEZONE="$(bashio::config 'Timezone' '!secret Timezone')"
CONFIG_BTCONNECTRETRIES="$(bashio::config 'BTConnectRetries' '10')"
CONFIG_CSV_EXPORT="$(bashio::config 'CSV_Export' '0')"
CONFIG_CSV_EXTENDEDHEADER="$(bashio::config 'CSV_ExtendedHeader' '1')"
CONFIG_CSV_HEADER="$(bashio::config 'CSV_Header' '1')"
CONFIG_CSV_SAVEZEROPOWER="$(bashio::config 'CSV_SaveZeroPower' '1')"
CONFIG_CSV_DELIMITER="$(bashio::config 'CSV_Delimiter' 'semicolon')"
CONFIG_CSV_SPOT_TIMESOURCE="$(bashio::config 'CSV_Spot_TimeSource' 'Inverter')"
CONFIG_CSV_SPOT_WEBBOXHEADER="$(bashio::config 'CSV_Spot_WebboxHeader' '0')"
CONFIG_SQL_DATABASE="$(bashio::config 'SQL_Database' 'SBFspot')"
CONFIG_SQL_HOSTNAME="$(bashio::config 'SQL_Hostname' 'core-mariadb')"
CONFIG_SQL_PORT="$(bashio::config 'SQL_Port' '3306')"
CONFIG_SQL_USERNAME="$(bashio::config 'SQL_Username' 'sbfspot')"
CONFIG_SQL_PASSWORD="$(bashio::config 'SQL_Password' '!secret mariadb_pw')"
CONFIG_MQTT_PUBLISHER="$(bashio::config 'MQTT_Publisher' '/usr/bin/mosquitto_pub')"
CONFIG_MQTT_HOST="$(bashio::config 'MQTT_Host' 'core-mosquitto')"
CONFIG_MQTT_PORT="$(bashio::config 'MQTT_Port')"
# CONFIG_MQTT_USER="$(bashio::config 'MQTT_User' '!secret mqtt_user')"
# CONFIG_MQTT_PASS="$(bashio::config 'MQTT_Pass' '!secret mqtt_pass')"
CONFIG_MQTT_TOPIC="$(bashio::config 'MQTT_Topic' 'homeassistant/sbfspot_{plantname}/sbfspot_{serial}')"
CONFIG_MQTT_ITEMFORMAT="$(bashio::config 'MQTT_ItemFormat' '"{key}": {value}')"
CONFIG_MQTT_ITEMDELIMITER="$(bashio::config 'MQTT_ItemDelimiter' 'comma')"
# CONFIG_MQTT_PUBLISHERARGS="$(bashio::config 'MQTT_PublisherArgs')"
CONFIG_MQTT_DATA="$(bashio::config 'MQTT_Data')"
# CONFIG_LOGDIR="$(bashio::config 'LogDir')"
CONFIG_LOGLEVEL="$(bashio::config 'LogLevel' 'info')"
CONFIG_PVOUTPUT_SID="$(bashio::config 'PVoutput_SID' '0123456789:12345')"
CONFIG_PVOUTPUT_KEY="$(bashio::config 'PVoutput_Key' 'fake9364fake4545afke834fake')"
cat > "$CFG_PATH" <<EOL
################################################################################
@ -134,7 +134,8 @@ 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_DATETIMEFORMAT
# DateTimeFormat= ###CONFIG_DATETIMEFORMAT
DateTimeFormat=%Y-%m-%dT%H:%M:%S%z
# DateFormat (default %d/%m/%Y)
DateFormat=$CONFIG_DATEFORMAT
@ -240,10 +241,11 @@ SQL_Password=$CONFIG_SQL_PASSWORD
MQTT_Publisher=$CONFIG_MQTT_PUBLISHER
MQTT_Host=$CONFIG_MQTT_HOST
MQTT_Port=$CONFIG_MQTT_PORT
MQTT_Topic=$CONFIG_MQTT_TOPIC
MQTT_ItemFormat=$CONFIG_MQTT_ITEMFORMAT
MQTT_ItemDelimiter=$CONFIG_MQTT_ITEMDELIMITER
MQTT_PublisherArgs=$CONFIG_MQTT_PUBLISHERARGS
MQTT_PublisherArgs=-h $(bashio::config 'MQTT_Host' 'core-mosquitto') -u $(bashio::config 'MQTT_User') -P $(bashio::config 'MQTT_Pass') -t {topic} -m "{{message}}" -d
MQTT_Data=$CONFIG_MQTT_DATA
EOL
@ -271,7 +273,7 @@ cat > "$CFG_PATH_UPLOAD" <<EOL
# Windows: C:\Users\Public\SMAdata\Logs
# Linux : /home/pi/smadata/logs
#LogDir=C:\Users\Public\SMAdata\Logs
LogDir=$CONFIG_LOGDIR
# LogDir= ### CONFIG_LOGDIR
#LogLevel=debug|info|warning|error (default info)
LogLevel=$CONFIG_LOGLEVEL
@ -309,4 +311,4 @@ EOL
# create folders
mkdir -p "$CONFIG_OUTPUTPATH"
mkdir -p "$CONFIG_LOGDIR"
# mkdir -p ##### "CONFIG_LOGDIR"

View file

@ -1,59 +1,58 @@
#!/usr/bin/with-contenv bashio
#export CFG_PATH
#export CFG_PATH_UPLOAD
CFG_PATH="${1}"
CFG_PATH_UPLOAD="${2}"
# CONFIG_PATH=/data/options.json
CFG_PATH=$1
CFG_PATH_UPLOAD=$2
CONFIG_PATH=/data/options.json
#CONFIG_CONNECTION_TYPE="$(jq --raw-output '.Connection_Type' $CONFIG_PATH)"
#CONFIG_BTADDRESS="$(jq --raw-output '.BTAddress' $CONFIG_PATH)"
#CONFIG_LOCALBTADDRESS="$(jq --raw-output '.LocalBTAddress' $CONFIG_PATH)"
CONFIG_IP_ADDRESS="$(jq --raw-output '.IP_Address' $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_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)"
# CONFIG_CONNECTION_TYPE="$(bashio::config 'Connection_Type')"
# CONFIG_BTADDRESS="$(bashio::config 'BTAddress' '!secret BTAdress')"
# CONFIG_LOCALBTADDRESS="$(bashio::config 'LocalBTAddress' '!secret LocalBTAddress')"
CONFIG_IP_ADDRESS="$(bashio::config 'IP_Address' '!secret IP_Address')"
CONFIG_PASSWORD="$(bashio::config 'Password' '!secret SBFpassword')"
CONFIG_MSI_ENABLED="$(bashio::config 'MIS_Enabled' '0')"
CONFIG_PLANTNAME="$(bashio::config 'Plantname')"
CONFIG_OUTPUTPATH="$(bashio::config 'OutputPath' '/data/sbfspot/%Y')"
CONFIG_OUTPUTPATHEVENTS="$(bashio::config 'OutputPathEvents' '/data/sbfspot/%Y/events')"
CONFIG_LATITUDE="$(bashio::config 'Latitude')"
CONFIG_LONGITUDE="$(bashio::config 'Longitude')"
CONFIG_CALCULATEMISSINGSPOTVALUES="$(bashio::config 'CalculateMissingSpotValues' '1')"
# CONFIG_DATETIMEFORMAT="$(bashio::config 'DateTimeFormat' '%Y-%m-%d%H:%M:%S%z')"
CONFIG_DATEFORMAT="$(bashio::config 'DateFormat' '%d/%m/%Y')"
CONFIG_DECIMALPOINT="$(bashio::config 'DecimalPoint' 'comma')"
CONFIG_TIMEFORMAT="$(bashio::config 'TimeFormat' '%H:%M:%S%')"
CONFIG_SYNCHTIME="$(bashio::config 'SynchTime' '0')"
CONFIG_SYNCHTIMELOW="$(bashio::config 'SynchTimeLow' '1')"
CONFIG_SYNCHTIMEHIGH="$(bashio::config 'SynchTimeHigh' '3600')"
CONFIG_SUNRSOFFSET="$(bashio::config 'SunRSOffset' '900')"
CONFIG_LOCALE="$(bashio::config 'Locale')"
CONFIG_TIMEZONE="$(bashio::config 'Timezone')"
CONFIG_BTCONNECTRETRIES="$(bashio::config 'BTConnectRetries' '10')"
CONFIG_CSV_EXPORT="$(bashio::config 'CSV_Export' '0')"
CONFIG_CSV_EXTENDEDHEADER="$(bashio::config 'CSV_ExtendedHeader' '1')"
CONFIG_CSV_HEADER="$(bashio::config 'CSV_Header' '1')"
CONFIG_CSV_SAVEZEROPOWER="$(bashio::config 'CSV_SaveZeroPower' '1')"
CONFIG_CSV_DELIMITER="$(bashio::config 'CSV_Delimiter' 'semicolon')"
CONFIG_CSV_SPOT_TIMESOURCE="$(bashio::config 'CSV_Spot_TimeSource' 'Inverter')"
CONFIG_CSV_SPOT_WEBBOXHEADER="$(bashio::config 'CSV_Spot_WebboxHeader' '0')"
CONFIG_SQL_DATABASE="$(bashio::config 'SQL_Database' 'SBFspot')"
CONFIG_SQL_HOSTNAME="$(bashio::config 'SQL_Hostname' 'core-mariadb')"
CONFIG_SQL_PORT="$(bashio::config 'SQL_Port' '3306')"
CONFIG_SQL_USERNAME="$(bashio::config 'SQL_Username' 'sbfspot')"
CONFIG_SQL_PASSWORD="$(bashio::config 'SQL_Password' '!secret mariadb_pw')"
CONFIG_MQTT_PUBLISHER="$(bashio::config 'MQTT_Publisher' '/usr/bin/mosquitto_pub')"
CONFIG_MQTT_HOST="$(bashio::config 'MQTT_Host' 'core-mosquitto')"
CONFIG_MQTT_PORT="$(bashio::config 'MQTT_Port')"
# CONFIG_MQTT_USER="$(bashio::config 'MQTT_User' '!secret mqtt_user')"
# CONFIG_MQTT_PASS="$(bashio::config 'MQTT_Pass' '!secret mqtt_pass')"
CONFIG_MQTT_TOPIC="$(bashio::config 'MQTT_Topic')"
CONFIG_MQTT_ITEMFORMAT="$(bashio::config 'MQTT_ItemFormat')"
CONFIG_MQTT_ITEMDELIMITER="$(bashio::config 'MQTT_ItemDelimiter' 'comma')"
# CONFIG_MQTT_PUBLISHERARGS="$(bashio::config 'MQTT_PublisherArgs')"
CONFIG_MQTT_DATA="$(bashio::config 'MQTT_Data')"
# CONFIG_LOGDIR="$(bashio::config 'LogDir')"
CONFIG_LOGLEVEL="$(bashio::config 'LogLevel' 'info')"
CONFIG_PVOUTPUT_SID="$(bashio::config 'PVoutput_SID' '0123456789:12345')"
CONFIG_PVOUTPUT_KEY="$(bashio::config 'PVoutput_Key' 'fake9364fake4545afke834fake')"
cat > "$CFG_PATH" <<EOL
################################################################################
@ -94,6 +93,7 @@ cat > "$CFG_PATH" <<EOL
# Multiple IP addresses can be provided (comma separated)
IP_Address=$CONFIG_IP_ADDRESS
# User password (default 0000)
Password=$CONFIG_PASSWORD
@ -136,7 +136,8 @@ 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_DATETIMEFORMAT
# DateTimeFormat= ###CONFIG_DATETIMEFORMAT
DateTimeFormat=%Y-%m-%dT%H:%M:%S%z
# DateFormat (default %d/%m/%Y)
DateFormat=$CONFIG_DATEFORMAT
@ -242,10 +243,11 @@ SQL_Password=$CONFIG_SQL_PASSWORD
MQTT_Publisher=$CONFIG_MQTT_PUBLISHER
MQTT_Host=$CONFIG_MQTT_HOST
MQTT_Port=$CONFIG_MQTT_PORT
MQTT_Topic=$CONFIG_MQTT_TOPIC
MQTT_ItemFormat=$CONFIG_MQTT_ITEMFORMAT
MQTT_ItemDelimiter=$CONFIG_MQTT_ITEMDELIMITER
MQTT_PublisherArgs=$CONFIG_MQTT_PUBLISHERARGS
MQTT_PublisherArgs=-h $(bashio::config 'MQTT_Host' 'core-mosquitto') -u $(bashio::config 'MQTT_User') -P $(bashio::config 'MQTT_Pass') -t {topic} -m "{{message}}" -d
MQTT_Data=$CONFIG_MQTT_DATA
EOL
@ -273,7 +275,7 @@ cat > "$CFG_PATH_UPLOAD" <<EOL
# Windows: C:\Users\Public\SMAdata\Logs
# Linux : /home/pi/smadata/logs
#LogDir=C:\Users\Public\SMAdata\Logs
LogDir=$CONFIG_LOGDIR
# LogDir= ### CONFIG_LOGDIR
#LogLevel=debug|info|warning|error (default info)
LogLevel=$CONFIG_LOGLEVEL
@ -311,4 +313,4 @@ EOL
# create folders
mkdir -p "$CONFIG_OUTPUTPATH"
mkdir -p "$CONFIG_LOGDIR"
# mkdir -p ##### "CONFIG_LOGDIR"

View file

@ -0,0 +1,246 @@
#!/usr/bin/with-contenv bashio
CFG_PATH=/usr/bin/sbfspot/SetConfig.cfg
CONFIG_PATH=/data/options.json
# MQTT_User="$(bashio::config 'MQTT_User' )"
# MQTT_Pass="$(bashio::config 'MQTT_Pass' )"
# CONFIG_CONNECTION_TYPE="$(bashio::config 'Connection_Type' )"
CONFIG_BTADDRESS="$(bashio::config 'BTAddress' '!secret BTAdress')"
CONFIG_LOCALBTADDRESS="$(bashio::config 'LocalBTAddress' '!secret LocalBTAddress')"
CONFIG_PASSWORD="$(bashio::config 'Password' '!secret SBFpassword')"
CONFIG_MSI_ENABLED="$(bashio::config 'MIS_Enabled' '0')"
CONFIG_PLANTNAME="$(bashio::config 'Plantname' )"
CONFIG_OUTPUTPATH="$(bashio::config 'OutputPath' '/data/sbfspot/%Y')"
CONFIG_OUTPUTPATHEVENTS="$(bashio::config 'OutputPathEvents' '/data/sbfspot/%Y/events')"
CONFIG_LATITUDE="$(bashio::config 'Latitude' '!secret home_lat')"
CONFIG_LONGITUDE="$(bashio::config 'Longitude' '!secret home_long')"
CONFIG_CALCULATEMISSINGSPOTVALUES="$(bashio::config 'CalculateMissingSpotValues' '1')"
# CONFIG_DATETIMEFORMAT="$(bashio::config 'DateTimeFormat' '%Y-%m-%d%H:%M:%S%z')"
CONFIG_DATEFORMAT="$(bashio::config 'DateFormat' '%d/%m/%Y')"
CONFIG_DECIMALPOINT="$(bashio::config 'DecimalPoint' 'comma')"
CONFIG_TIMEFORMAT="$(bashio::config 'TimeFormat' '%H:%M:%S%')"
CONFIG_SYNCHTIME="$(bashio::config 'SynchTime' '0')"
CONFIG_SYNCHTIMELOW="$(bashio::config 'SynchTimeLow' '1')"
CONFIG_SYNCHTIMEHIGH="$(bashio::config 'SynchTimeHigh' '3600')"
CONFIG_SUNRSOFFSET="$(bashio::config 'SunRSOffset' '900')"
CONFIG_LOCALE="$(bashio::config 'Locale' 'en-US' '!secret Timezone')"
CONFIG_TIMEZONE="$(bashio::config 'Timezone' )"
CONFIG_BTCONNECTRETRIES="$(bashio::config 'BTConnectRetries' '10')"
# CONFIG_CSV_EXPORT="$(bashio::config 'CSV_Export' '0')"
CONFIG_CSV_EXTENDEDHEADER="$(bashio::config 'CSV_ExtendedHeader' '1')"
CONFIG_CSV_HEADER="$(bashio::config 'CSV_Header' '1')"
CONFIG_CSV_SAVEZEROPOWER="$(bashio::config 'CSV_SaveZeroPower' '1')"
CONFIG_CSV_DELIMITER="$(bashio::config 'CSV_Delimiter' 'semicolon')"
CONFIG_CSV_SPOT_TIMESOURCE="$(bashio::config 'CSV_Spot_TimeSource' 'Inverter')"
CONFIG_CSV_SPOT_WEBBOXHEADER="$(bashio::config 'CSV_Spot_WebboxHeader' '0')"
CONFIG_SQL_DATABASE="$(bashio::config 'SQL_Database' 'SBFspot')"
CONFIG_SQL_HOSTNAME="$(bashio::config 'SQL_Hostname' 'core-mariadb')"
CONFIG_SQL_PORT="$(bashio::config 'SQL_Port' '3306')"
CONFIG_SQL_USERNAME="$(bashio::config 'SQL_Username' 'sbfspot')"
CONFIG_SQL_PASSWORD="$(bashio::config 'SQL_Password' '!secret mariadb_pw')"
CONFIG_MQTT_PUBLISHER="$(bashio::config 'MQTT_Publisher' '/usr/bin/mosquitto_pub')"
CONFIG_MQTT_HOST="$(bashio::config 'MQTT_Host' 'core-mosquitto')"
CONFIG_MQTT_PORT="$(bashio::config 'MQTT_Port' )"
# CONFIG_MQTT_USER="$(bashio::config 'MQTT_User' '!secret mqtt_user')"
# CONFIG_MQTT_PASS="$(bashio::config 'MQTT_Pass' '!secret mqtt_pass')"
# CONFIG_MQTT_TOPIC="$(bashio::config 'MQTT_Topic' 'homeassistant/sbfspot_{plantname}/sbfspot_{serial}')"
CONFIG_MQTT_ITEMFORMAT="$(bashio::config 'MQTT_ItemFormat' '"{key}": {value}')"
CONFIG_MQTT_ITEMDELIMITER="$(bashio::config 'MQTT_ItemDelimiter' 'comma')"
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
# If multiple local BT adapters are available, select the one to use
LocalBTAddress=$CONFIG_LOCALBTADDRESS
# 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_DATETIMEFORMAT
DateTimeFormat=%Y-%m-%dT%H:%M:%S%z
# 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=0
# 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_Topic=$(bashio::addon.name)/device
MQTT_ItemFormat=$CONFIG_MQTT_ITEMFORMAT
MQTT_ItemDelimiter=$CONFIG_MQTT_ITEMDELIMITER
MQTT_PublisherArgs=-h {host} -u "$(bashio::config 'MQTT_User' 'core-mosquitto')" -P "$(bashio::config 'MQTT_Pass')" -t {topic} -m "{{message}}" -d -r
MQTT_Data=InvSerial,InvName,InvClass,InvType,InvSwVer
EOL

View file

@ -0,0 +1,247 @@
#!/usr/bin/with-contenv bashio
CFG_PATH=/usr/bin/sbfspot/SetConfig.cfg
# CONFIG_PATH=/data/options.json
# CONFIG_CONNECTION_TYPE="$(bashio::config 'Connection_Type' )"
# CONFIG_BTADDRESS="$(bashio::config 'BTAddress' '!secret BTAdress')"
# CONFIG_LOCALBTADDRESS="$(bashio::config 'LocalBTAddress' '!secret LocalBTAddress')"
CONFIG_IP_ADDRESS="$(bashio::config 'IP_Address' '!secret IP_Address')"
CONFIG_PASSWORD="$(bashio::config 'Password' '!secret SBFpassword')"
CONFIG_MSI_ENABLED="$(bashio::config 'MIS_Enabled' '0')"
CONFIG_PLANTNAME="$(bashio::config 'Plantname' )"
CONFIG_OUTPUTPATH="$(bashio::config 'OutputPath' '/data/sbfspot/%Y')"
CONFIG_OUTPUTPATHEVENTS="$(bashio::config 'OutputPathEvents' '/data/sbfspot/%Y/events')"
CONFIG_LATITUDE="$(bashio::config 'Latitude' '!secret home_lat')"
CONFIG_LONGITUDE="$(bashio::config 'Longitude' '!secret home_long')"
CONFIG_CALCULATEMISSINGSPOTVALUES="$(bashio::config 'CalculateMissingSpotValues' '1')"
# CONFIG_DATETIMEFORMAT="$(bashio::config 'DateTimeFormat' '%Y-%m-%d%H:%M:%S%z')"
CONFIG_DATEFORMAT="$(bashio::config 'DateFormat' '%d/%m/%Y')"
CONFIG_DECIMALPOINT="$(bashio::config 'DecimalPoint' 'comma')"
CONFIG_TIMEFORMAT="$(bashio::config 'TimeFormat' '%H:%M:%S%')"
CONFIG_SYNCHTIME="$(bashio::config 'SynchTime' '0')"
CONFIG_SYNCHTIMELOW="$(bashio::config 'SynchTimeLow' '1')"
CONFIG_SYNCHTIMEHIGH="$(bashio::config 'SynchTimeHigh' '3600')"
CONFIG_SUNRSOFFSET="$(bashio::config 'SunRSOffset' '900')"
CONFIG_LOCALE="$(bashio::config 'Locale' 'en-US' '!secret Timezone')"
CONFIG_TIMEZONE="$(bashio::config 'Timezone' )"
CONFIG_BTCONNECTRETRIES="$(bashio::config 'BTConnectRetries' '10')"
# CONFIG_CSV_EXPORT="$(bashio::config 'CSV_Export' '0')"
CONFIG_CSV_EXTENDEDHEADER="$(bashio::config 'CSV_ExtendedHeader' '1')"
CONFIG_CSV_HEADER="$(bashio::config 'CSV_Header' '1')"
CONFIG_CSV_SAVEZEROPOWER="$(bashio::config 'CSV_SaveZeroPower' '1')"
CONFIG_CSV_DELIMITER="$(bashio::config 'CSV_Delimiter' 'semicolon')"
CONFIG_CSV_SPOT_TIMESOURCE="$(bashio::config 'CSV_Spot_TimeSource' 'Inverter')"
CONFIG_CSV_SPOT_WEBBOXHEADER="$(bashio::config 'CSV_Spot_WebboxHeader' '0')"
CONFIG_SQL_DATABASE="$(bashio::config 'SQL_Database' 'SBFspot')"
CONFIG_SQL_HOSTNAME="$(bashio::config 'SQL_Hostname' 'core-mariadb')"
CONFIG_SQL_PORT="$(bashio::config 'SQL_Port' '3306')"
CONFIG_SQL_USERNAME="$(bashio::config 'SQL_Username' 'sbfspot')"
CONFIG_SQL_PASSWORD="$(bashio::config 'SQL_Password' '!secret mariadb_pw')"
CONFIG_MQTT_PUBLISHER="$(bashio::config 'MQTT_Publisher' '/usr/bin/mosquitto_pub')"
CONFIG_MQTT_HOST="$(bashio::config 'MQTT_Host' 'core-mosquitto')"
CONFIG_MQTT_PORT="$(bashio::config 'MQTT_Port' )"
# CONFIG_MQTT_USER="$(bashio::config 'MQTT_User' '!secret mqtt_user')"
# CONFIG_MQTT_PASS="$(bashio::config 'MQTT_Pass' '!secret mqtt_pass')"
# CONFIG_MQTT_TOPIC="$(bashio::config 'MQTT_Topic' 'homeassistant/sbfspot_{plantname}/sbfspot_{serial}')"
CONFIG_MQTT_ITEMFORMAT="$(bashio::config 'MQTT_ItemFormat' '"{key}": {value}')"
CONFIG_MQTT_ITEMDELIMITER="$(bashio::config 'MQTT_ItemDelimiter' 'comma')"
# CONFIG_MQTT_PUBLISHERARGS="$(jq --raw-output '.MQTT_PublisherArgs' $CONFIG_PATH)"
# CONFIG_MQTT_DATA="$(jq --raw-output '.MQTT_Data' $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=
# If multiple local BT adapters are available, select the one to use
# LocalBTAddress=
# 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=$CONFIG_IP_ADDRESS
# 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_DATETIMEFORMAT
DateTimeFormat=%Y-%m-%dT%H:%M:%S%z
# 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=0
# 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_Topic=$(bashio::addon.name)/device
MQTT_ItemFormat=$CONFIG_MQTT_ITEMFORMAT
MQTT_ItemDelimiter=$CONFIG_MQTT_ITEMDELIMITER
MQTT_PublisherArgs=-h {host} -u "$(bashio::config 'MQTT_User')" -P "$(bashio::config 'MQTT_Pass')" -t {topic} -m "{{message}}" -d -r
MQTT_Data=InvSerial,InvName,InvClass,InvType,InvSwVer
EOL

View file

@ -0,0 +1,809 @@
#!/usr/bin/with-contenv bashio
#
# Publish MQTT sensors for Config discovery.
set -e
CONFIG_PATH=/data/options.json
PLANTNAME="$(bashio::config 'Plantname')"
MQTT_Host="$(bashio::config 'MQTT_Host' 'core-mosquitto')"
MQTT_User="$(bashio::config 'MQTT_User')"
MQTT_Pass="$(bashio::config 'MQTT_Pass')"
MQTT_Topic="$(bashio::config 'MQTT_Topic')"
MQTT_Data="$(bashio::config 'MQTT_Data')"
# arg="$(jq --raw-output '.MQTT_Data' /data/options.json | tr ',' '\n')"
ts="$(bashio::config 'DateTimeFormat' '%H:%M:%S %d/%m/%Y')"
bashio::log.magenta "$PLANTNAME"
bashio::log.red "${MQTT_Host}"
bashio::log.green "${MQTT_User}"
# echo "${MQTT_Pass}"
bashio::log.blue "${MQTT_Topic}"
bashio::log.cyan "${MQTT_Data}"
# make set config
if bashio::fs.file_exists '/data/device'; then
bashio::log.info Using Existing Device info
else
value="$(bashio::config 'Connection_Type')"
if bashio::var.equals "${value}" "Bluetooth"; then
/usr/bin/sbfspot/genSenBlue
bashio::log.info
bashio::log.info
bashio::log.info "${__BASHIO_COLORS_BLUE}" "|| Generating HA Sensors ||"
# Use SetConfig.cfg to post initial mqtt msg for sensors
/usr/bin/sbfspot/SBFspot -v -finq -mqtt -cfg/usr/bin/sbfspot/SetConfig.cfg
# Subscribe to read SBFspot sensor post
mosquitto_sub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t "$(bashio::addon.name)/device" -C 1 > /data/device
elif bashio::var.equals "${value}" "Ethernet"; then
/usr/bin/sbfspot/genSenEth
bashio::log.info
bashio::log.info
message=$(echo "|| Generating HA Sensors ||")
bashio::log.info "${__BASHIO_COLORS_MAGENTA}" "${message:=""}"
# Use SetConfig.cfg to post initial mqtt msg for sensors
/usr/bin/sbfspot/SBFspot -v -finq -mqtt -cfg/usr/bin/sbfspot/SetConfig.cfg
# Subscribe to read SBFspot sensor post
mosquitto_sub -h "${MQTT_Host}" -u "${MQTT_User}" -P "${MQTT_Pass}" -t "$(bashio::addon.name)/device" -C 1 > /data/device
else
bashio::log.info "${__BASHIO_COLORS_RED}" ===================================
bashio::log.info "${__BASHIO_COLORS_RED}" "Setup failed to create HA Sensors"
bashio::log.info "${__BASHIO_COLORS_RED}" ===================================
fi
fi
DEVICE_PATH=/data/device
InvSerial="$(jq --raw-output '.InvSerial' $DEVICE_PATH)" # <<< ---- change to Dummy serial if needed to get from mqtt
InvName="$(jq --raw-output '.InvName' $DEVICE_PATH)" # <<< ---- prints bad formant SN: SerialNo or perhaps not
InvSwVer="$(jq --raw-output '.InvSwVer' $DEVICE_PATH)"
InvType="$(jq --raw-output '.InvType' $DEVICE_PATH)"
InvClass="$(jq --raw-output '.InvClass' $DEVICE_PATH)"
BTmac="$(jq --raw-output '.BTAddress' /data/options.json | tr -d ':' )" # <<< --- Compress BT MAC to use in Unique ID
bashio::log "$(cat "$DEVICE_PATH" | jq -C )"
#bashio::log.info "${__BASHIO_COLORS_RED}" "${InvSerial}"
#bashio::log.info "${__BASHIO_COLORS_RED}" "${InvName}"
#bashio::log.info "${__BASHIO_COLORS_RED}" "${InvSwVer}"
#bashio::log.info "${__BASHIO_COLORS_RED}" "${InvType}"
#bashio::log.info "${__BASHIO_COLORS_RED}" "${InvClass}"
#bashio::log.info "${__BASHIO_COLORS_RED}" "${BTmac}"
# Can this be used to send to options or cache?
#bashio::addon.option 'InvSerial' "${InvSerial}"
bashio::log.cyan "${InvSerial}"
debugMQTT='--quiet' # debug '-d' or '--quiet'
RoK='-r' # retain '-r' or '-d' depending on value above
# Array stuff #### https://stackoverflow.com/questions/3685970/check-if-a-bash-array-contains-a-value
#if [[ " ${array[*]} " =~ " ${value} " ]]; then
# # whatever you want to do when array contains value
#fi
#
#if [[ ! " ${array[*]} " =~ " ${value} " ]]; then
# # whatever you want to do when array doesn't contain value
#fi
#
## ALL MQTT_Data Option Values ARRAY creation ## https://riptutorial.com/bash/example/27007/split-string-into-an-array-in-bash
IFS=',' read -r -a array <<< "$MQTT_Data"
bashio::log.magenta "${array[@]}"
###### MAKE SENSORS #######
value='InvName'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Inverter Nom'
mdi_icon='mdi:card-bulleted'
# devClass= << add in \"device_class\": \"$devClass\",
# stClass= << add in \"state_class\": \"$stClass\",
# UoM= << add in \"unit_of_measurement\": \"$UoM\",
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "${value}"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='Timestamp'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Timestamp'
mdi_icon='mdi:clock-digital'
devClass='timestamp' # 'timestamp' fiddly needs to be correctly formatted with TZ data <<# #>> null none empty not allowed. #\"device_class\": \"$devClass\",#
stClass=
UoM=
EnabDef='true'
ent_cat= ### diagnostic config sensor # sensor can't be sent so # \"entity_category\": \"$ent_cat\", # removed https://developers.home-assistant.io/docs/core/entity
bashio::log.info Setting Up "${value}"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"device_class\": \"$devClass\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvTime'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Time Inverter'
mdi_icon='mdi:clock'
devClass='timestamp' ### class removed to allow custom timestamps for InvTime SunRise and SunSet
stClass=
UoM=
EnabDef='true'
ent_cat='diagnostic'
ts="$(bashio::config 'DateTimeFormat')"
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | as_timestamp | timestamp_custom( $ts ) | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='SunRise'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Sun Rise'
mdi_icon='mdi:weather-sunny'
devClass= ### no class for timestamp custom
stClass=
UoM=
EnabDef='true'
ent_cat=
ts="$(bashio::config 'DateTimeFormat')"
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | as_timestamp | timestamp_custom( $ts ) | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='SunSet'
if [[ " ${array[*]} " =~ " $value " ]]; then
value='SunSet'
describe='SMA Sun Set'
mdi_icon='mdi:weather-hazy'
devClass= ### no class for timestamp custom
stClass=
UoM=
EnabDef='true'
ent_cat=
ts="$(bashio::config 'DateTimeFormat')"
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | as_timestamp | timestamp_custom( $ts ) | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvSerial'
if [[ " ${array[*]} " =~ " $value " ]]; then
value='InvSerial'
describe='SMA Serial No'
mdi_icon='mdi:card-bulleted-settings'
devClass=
stClass=
UoM=
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvClass'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA device type'
mdi_icon='mdi:cupboard-outline'
devClass=
stClass=
UoM=
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvType'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA device Model'
mdi_icon='mdi:card-bulleted-settings'
devClass=
stClass=
UoM=
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvSwVer'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA device Firmware'
mdi_icon=mdi:select-inverse
devClass=
stClass=
UoM=
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvStatus'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Inverter Status'
mdi_icon=mdi:select-inverse
devClass=
stClass=
UoM=
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvTemperature'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Inverter Running Temp'
mdi_icon='mdi:coolant-temperature'
devClass='temperature'
stClass='measurement'
UoM='°C'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='InvGridRelay'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA device Grid Relay'
mdi_icon='mdi:electric-switch'
devClass=
stClass=
UoM=
EnabDef='false'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='EToday'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Energy Daily'
mdi_icon='mdi:solar-power-variant'
devClass='energy'
stClass='total_increasing'
UoM='kWh'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='ETotal'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Energy Lifetime'
mdi_icon='mdi:solar-power-variant'
devClass='energy'
stClass='total_increasing'
UoM='kWh'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PACTot'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA AC Power'
mdi_icon='mdi:solar-power-variant'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='UDC1'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Array UDC'
mdi_icon='mdi:solar-panel-large'
devClass='voltage'
stClass='measurement'
UoM='V'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='UDC2'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Array2 UDC'
mdi_icon='mdi:solar-panel'
devClass='voltage'
stClass='measurement'
UoM='V'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='IDC1'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Array IDC'
mdi_icon='mdi:solar-panel-large'
devClass='current'
stClass='measurement'
UoM='A'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='IDC2'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Array2 IDC'
mdi_icon='mdi:solar-panel'
devClass='current'
stClass='measurement'
UoM='A'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PDC1'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Array PDC'
mdi_icon='mdi:solar-panel-large'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PDC2'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Array2 PDC'
mdi_icon='mdi:solar-panel'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PDCTot'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA DC All Strings'
mdi_icon='mdi:solar-power-variant-outline'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='OperTm'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Total Op Time'
mdi_icon='mdi:clock'
devClass='duration'
stClass='total_increasing'
UoM='h'
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='FeedTm'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Total Feed In Time'
mdi_icon='mdi:clock-digital'
devClass='duration'
stClass='total_increasing'
UoM='h'
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PAC1'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA AC Power Line 1'
mdi_icon='mdi:transmission-tower'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PAC2'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA AC Power Line 2'
mdi_icon='mdi:transmission-tower'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='PAC3'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA AC Power Line 3'
mdi_icon='mdi:transmission-tower'
devClass='power'
stClass='measurement'
UoM='W'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='UAC1'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Phase 1 Voltage'
mdi_icon='mdi:transmission-tower'
devClass='voltage'
stClass='measurement'
UoM='V'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='UAC2'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Phase 2 Voltage'
mdi_icon='mdi:transmission-tower'
devClass='voltage'
stClass='measurement'
UoM='V'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='UAC3'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Phase 3 Voltage'
mdi_icon='mdi:transmission-tower'
devClass='voltage'
stClass='measurement'
UoM='V'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='IAC1'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Phase 1 Current'
mdi_icon='mdi:transmission-tower'
devClass='current'
stClass='measurement'
UoM='A'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='IAC2'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Phase 2 Current'
mdi_icon='mdi:transmission-tower'
devClass='current'
stClass='measurement'
UoM='A'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='IAC3'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Phase 3 Current'
mdi_icon='mdi:transmission-tower'
devClass='current'
stClass='measurement'
UoM='A'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='GridFreq'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Grid Frequency'
mdi_icon='mdi:transmission-tower'
devClass='frequency'
stClass='measurement'
UoM='Hz'
EnabDef='true'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='BTSignal'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Bluetooth Signal'
mdi_icon='mdi:bluetooth'
devClass='signal_strength'
stClass='measurement'
UoM='dB'
EnabDef='true'
ent_cat='diagnostic'
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | round(1) | default(0) }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"entity_category\": \"$ent_cat\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='BatTmpVal'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Battery Temp'
mdi_icon='mdi:home-battery-outline'
devClass='temperature'
stClass='measurement'
UoM='°C'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='BatVol'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Battery Voltage'
mdi_icon='mdi:battery-charging-medium'
devClass='voltage'
stClass='measurement'
UoM='V'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
value='BatAmp'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Battery Current'
mdi_icon='mdi:battery-charging-medium'
devClass='current'
stClass='measurement'
UoM='A'
EnabDef='false'
ent_cat=
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi
#set -x
value='BatChaStt'
if [[ " ${array[*]} " =~ " $value " ]]; then
describe='SMA Battery Charging'
mdi_icon='mdi:battery-clock'
devClass='battery'
stClass='total'
UoM='%'
EnabDef='false'
ent_cat= ## enabled_by_default boolean (optional, default: true) ##disabled_by # "user"? or null or integration? doesn't work.
bashio::log.info Setting Up "$value"
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value | default() }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\", \"unit_of_measurement\": \"$UoM\", \"enabled_by_default\": \"$EnabDef\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" "$debugMQTT" "$RoK"
else
bashio::log.yellow Skipping "${value}"
fi

View file

@ -0,0 +1,359 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# Publish MQTT sensors for Config discovery.
#set -x
CONFIG_PATH=/data/options.json
PLANTNAME="$(bashio::config 'Plantname')"
MQTT_Host="$(bashio::config 'MQTT_Host' 'core-mosquitto')"
MQTT_User="$(bashio::config 'MQTT_User' '!secret mqtt_user')"
MQTT_Pass="$(bashio::config 'MQTT_Pass' '!secret mqtt_pass')"
MQTT_Topic="$(bashio::config 'MQTT_Topic')"
MQTT_Data="$(bashio::config 'MQTT_Data')"
# make set config
# mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t "$(bashio::addon.name)/device" -m "{\"SensorsHA\": \"Purge\"}" -r ### why??>> /data/options.json
# make set config
if bashio::fs.file_exists '/data/device'; then
bashio::log.green "{ Using Existing Device info }"
else
value="$(bashio::config 'Connection_Type')"
if bashio::var.equals "${value}" "Bluetooth"; then
/usr/bin/sbfspot/genSenBlue
bashio::log.info
bashio::log.info
bashio::log.info "${__BASHIO_COLORS_BLUE}" "|| Collecting Inv Serial ||"
# Use SetConfig.cfg to post initial mqtt msg for sensors
/usr/bin/sbfspot/SBFspot -v -finq -mqtt -cfg/usr/bin/sbfspot/SetConfig.cfg
# Subscribe to read SBFspot sensor post
mosquitto_sub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t "$(bashio::addon.name)/device" -C 1 > /data/device
elif bashio::var.equals "${value}" "Ethernet"; then
/usr/bin/sbfspot/genSenEth
bashio::log.info
bashio::log.info
message=$(echo "|| Collecting Inv Serial ||")
bashio::log.info "${__BASHIO_COLORS_MAGENTA}" "${message:=""}"
# Use SetConfig.cfg to post initial mqtt msg for sensors
/usr/bin/sbfspot/SBFspot -v -finq -mqtt -cfg/usr/bin/sbfspot/SetConfig.cfg
# Subscribe to read SBFspot sensor post
mosquitto_sub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t "$(bashio::addon.name)/device" -C 1 > /data/device
else
bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
bashio::log.info "${__BASHIO_COLORS_RED}" '| "Failed Purge HA Sensors" |'
bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
fi
fi
#### Why here? should be somewhere else like run
#value="$(jq --raw-output '.SensorsHA' $CONFIG_PATH)"
#if bashio::var.equals "${value}" "Create"; then
# /usr/bin/sbfspot/genSenBlue.sh
# bashio::log.info
# bashio::log.info "${__BASHIO_COLORS_BLUE}" "|| HA Sensors Exist ||"
# bashio::log.info
#elif bashio::var.equals "${value}" "Purge"; then
# bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
# bashio::log.info "${__BASHIO_COLORS_RED}" '| "Purge Retained HA Sensors" |'
# bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
#else
# bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
# bashio::log.info "${__BASHIO_COLORS_RED}" '| "Purge HA MQTT Sensors" |'
# bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
#fi
# Use SetConfig.cfg to post initial mqtt msg for sensors
# /usr/bin/sbfspot/SBFspot -v -finq -mqtt -cfg/usr/bin/sbfspot/SetConfig.cfg
#
# ALL Values
# MQTT_Data=Timestamp,InvTime,SunRise,SunSet,InvSerial,InvName,InvClass,InvType,InvSwVer,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,PACTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,PDCTot,OperTm,FeedTm,PAC1,PAC2,PAC3,UAC1,UAC2,UAC3,IAC1,IAC2,IAC3,GridFreq,BTSignal,BatTmpVal,BatVol,BatAmp,BatChaStt
#
# Known Working MQTT msg and variables
#
# value='InvName' << -- Change to value you need
# describe='SMA Inverter Nom' << -- Short descriptuion for HA Name
# mdi_icon='mdi:flash' << -- mdi icons
#
# /usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" -r
#
# dev state icon uom
# /usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "{\"name\": \"$describe\", \"state_topic\": \"homeassistant/sbfspot_$PLANTNAME/sbfspot_$InvSerial\", \"value_template\": \"{{ value_json.$value }}\", \"unique_id\": \"$InvSerial"'_'"$value\", \"device_class\": \"$devClass\", \"state_class\": \"$stClass\" \"unit_of_measurement\": \"$UoM\", \"icon\": \"$mdi_icon\", \"device\": { \"identifiers\": [\"$(bashio::addon.name)""-Sensors\"], \"name\": \"HAOS-SBFspot\", \"model\": \"$InvType\", \"manufacturer\": \"SMA\", \"sw_version\": \"$InvSwVer\" }}" -r
#set -x
# Subscribe to read SBFspot sensor post
mosquitto_sub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t "$(bashio::addon.name)/device" -C 1 > /data/device
DEVICE_PATH=/data/device
bashio::log "$(cat "$DEVICE_PATH" | jq -C )"
InvSerial="$(jq --raw-output '.InvSerial' $DEVICE_PATH)" # <<< ---- change to Dummy serial if needed to get from mqtt
InvName="$(jq --raw-output '.InvName' $DEVICE_PATH)" # <<< ---- prints bad formant SN: SerialNo
InvSwVer="$(jq --raw-output '.InvSwVer' $DEVICE_PATH)"
InvType="$(jq --raw-output '.InvType' $DEVICE_PATH)"
InvClass="$(jq --raw-output '.InvClass' $DEVICE_PATH)"
if bashio::config 'InvSerial' 'InvSerial'; then
bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
bashio::log.info "${__BASHIO_COLORS_YELLOW}" '| "Purge HA MQTT Sensors" |'
bashio::log.info "${__BASHIO_COLORS_RED}" '==================================='
else
bashio::log.info "${__BASHIO_COLORS_RED}" '| "Boom BOOM BOOOOOOOMMM" |'
bashio::log.info "${__BASHIO_COLORS_RED}" '| "Sending Empty MQTT MSGs" |'
bashio::log.info "${__BASHIO_COLORS_RED}" '| "Check Removal MQTT Broker" |'
fi
if bashio::var.has_value "${MQTT_Data}" "InvName" ; then
value='InvName'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value 'Timestamp' ; then
value='Timestamp'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvTime" ; then
value='InvTime'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "SunRise" ; then
value='SunRise'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "SunSet" ; then
value='SunSet'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvSerial" ; then
value='InvSerial'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvClass" ; then
value='InvClass'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvType" ; then
value='InvType'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvSwVer" ; then
value='InvSwVer'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvStatus" ; then
value='InvStatus'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvTemperature" ; then
value='InvTemperature'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "InvGridRelay" ; then
value='InvGridRelay'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "EToday" ; then
value='EToday'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "ETotal" ; then
value='ETotal'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PACTot" ; then
value='PACTot'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "UDC1" ; then
value='UDC1'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "UDC2" ; then
value='UDC2'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "IDC1" ; then
value='IDC1'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "IDC2" ; then
value='IDC2'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PDC1" ; then
value='PDC1'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PDC2" ; then
value='PDC2'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PDCTot" ; then
value='PDCTot'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "OperTm" ; then
value='OperTm'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "FeedTm" ; then
value='FeedTm'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PAC1" ; then
value='PAC1'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PAC2" ; then
value='PAC2'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "PAC3" ; then
value='PAC3'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "UAC1" ; then
value='UAC1'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "UAC2" ; then
value='UAC2'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "UAC3" ; then
value='UAC3'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "IAC1" ; then
value='IAC1'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "IAC2" ; then
value='IAC2'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "IAC3" ; then
value='IAC3'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "GridFreq" ; then
value='GridFreq'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "BTSignal" ; then
value='BTSignal'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "BatTmpVal" ; then
value='BatTmpVal'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "BatVol" ; then
value='BatVol'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "BatAmp" ; then
value='BatAmp'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
if bashio::var.has_value "${MQTT_Data}" "BatChaStt" ; then
value='BatChaStt'
/usr/bin/mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sensor/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial""$value"/config -m "" -r
fi
# remove device info from default topic and device topic
mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t homeassistant/sbfspot_"$PLANTNAME"/sbfspot_"$InvSerial" -m "" -r
mosquitto_pub -h "$MQTT_Host" -u "$MQTT_User" -P "$MQTT_Pass" -t "$(bashio::addon.name)/device" -m "" -r
bashio::log.info "${__BASHIO_COLORS_RED}" '| "Boom BOOM BOOOOOOOMMM" |'
bashio::log.info "${__BASHIO_COLORS_RED}" '| "deleting /data/device" |'
rm /data/device

View file

@ -3,25 +3,25 @@
cd /
#---- Create lognow variable
lognow=$(date +%Y%m%d)
# Sleep until log updated from last SBFspot run
sleep 45
# lognow=$(date +%Y%m%d)
#---- set tail to log out to HA log
#---- Use lognow variable to select latest file
#---- Print tail of latest log
#message=$(echo "[SBFspot Upload Log Latest] $(tail -n1 /data/sbfspot/log/SBFspotUpload$lognow.log)")
#bashio::log.info "${message:="Hello World..."}"
# message=$(echo "[SBFspot Upload Log Latest] $(tail -n1 /data/sbfspot/log/SBFspotUpload$lognow.log)")
# bashio::log.info "${message:="Hello World..."}"
## Print the message the user supplied, defaults to "Hello World..."
bashio::log.info "[SBFspot Upload Log Latest] $(tail -n1 "/data/sbfspot/log/SBFspotUpload$lognow.log")"
# Sleep until log updated from last SBFspot run
sleep 45
bashio::log.info "[SBFspot Upload Log Latest]" #$(tail -n1 "/data/sbfspot/log/SBFspotUpload$lognow.log")"
# just used for timestamp display in logs.
#---- Delete old log files
#busybox command for minus 1 day
#date +%Y%m%d -d @$(($(date +%s)-86400))
# remove log files older than 3 days
find /data/sbfspot/log -mtime +3 -exec rm {} \;
# remove log files older than 3 days no longer required, however keeping for the message in the log.
## find /data/sbfspot/log -mtime +3 -exec rm {} \;

View file

@ -4,16 +4,20 @@ configuration:
name: Connection Type
description: >-
Pick Bluetooth or Ethernet, only the related options are generated in SBFspot.cfg
Sensors_HA:
name: Create or Purge Sensors for the MQTT integration.
description: >-
If you have exisiting yaml sensors, backup and remove them prior to avoid naming conflicts.
BTAddress:
name: Bluetooth Mac
name: Bluetooth Mac !secret BTAddress is Default
description: >-
Your Inverter Bluetooth MAC Address
Password:
name: Password
name: Password !secret SBFpassword is Default
description: >-
Inverter password - usually 0000 or Sunny Explorer password.
LocalBTAddress:
name: Host BT MAC
name: Host BT MAC !secret LocalBTAddress
description: >-
Your Host Bluetooth MAC. It is shown in the logs. It can be Blank.
IP_Address:
@ -25,23 +29,23 @@ configuration:
description: >-
It is only for Bluetooth multi inverter systems.
Plantname:
name: Plant Name
name: Plant Name !secret Plantname
description: >-
Plant name is included to your mqtt topic.
Plant name is used to create your mqtt topic.
OutputPath:
name: Data path
description: >-
/data/sbfspot/%Y is default. This is a dummy path for config generation.
/data/sbfspot/%Y is default. Set to default now! Leave empty!
OutputPathEvents:
name: Events Path
description: >-
/data/sbfspot/%Y/events is default. This is a dummy for config generation.
/data/sbfspot/%Y/events is default. Set to default now! Leave empty!
Latitude:
name: Latitude
name: Latitude !secret home_lat
description: >-
Position of pv-plant http://itouchmap.com/latlong.html
Longitude:
name: Longitude
name: Longitude !secret home_long
description: >-
Example for Ukkel, Belgium Latitude=50.80 Longitude=4.33
CalculateMissingSpotValues:
@ -49,11 +53,11 @@ configuration:
description: >-
If set to 1, values not provided by inverter will be calculated. eg: Pdc1 = Idc1 * Udc1
DateTimeFormat:
name: Date and Tiem format
name: Date and Time format for InvTime SunRise and SunSet.
description: >-
DateTimeFormat (default %d/%m/%Y %H:%M:%S) see strftime() function
Custom time display for InvTime SunRise and SunSet (looks nice '%H:%M:%S %d/%m/%Y' ) see strftime() function
SynchTime:
name: Inverter Sync Time
name: Inverter Sync Time. Default is 0 if left blank
description: >-
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
SynchTimeLow:
@ -72,20 +76,20 @@ configuration:
description: >-
Default en-US Supported locales: de-DE;en-US;fr-FR;nl-NL;es-ES;it-IT
Timezone:
name: Timezone
name: Timezone !secret Timezone
description: Europe/Brussels
BTConnectRetries:
name: BT connection attempts
description: >-
Number of Bluetooth Connection attempts (1-15; Default=10)
Number of Bluetooth Connection attempts (1-15; Default=10) Leave blank!
CSV_Export:
name: CSV Export
name: CSV Export Leave blank! in theory you can send csv to the outputpath..
description: >-
CSV Export to data path. Leave off. Data paths are not maintained for file deletion.
SQL_Database:
name: SQL DB Name.
description: >-
The name of your SBFspot DB.
The name of your SBFspot DB. SBFspot is default.
SQL_Hostname:
name: MariaDB hostname or IP
description: >-
@ -98,10 +102,14 @@ configuration:
name: SQL User
description: >-
User and Pass need to be created in MariaDB addon. myPHPadmin addon can be used for Initial DB table creation see readme for link to creation file.
SQL_Password:
name: SQL password !secret mariadb_pw
description: >-
User and Pass need to be created in MariaDB addon. !secret mariadb_pw is default!
MQTT_Publisher:
name: MQTT publish binary path.
description: >-
/usr/bin/mosquitto_pub is correct.
/usr/bin/mosquitto_pub is correct. Leave blank it will default!
MQTT_Host:
name: MQTT Host
description: >-
@ -111,45 +119,45 @@ configuration:
description: >-
1883 is default. Can be Blank.
MQTT_User:
name: MQTT User
name: MQTT User !secret mqtt_user is default!
description: >-
"$MQTT_User" is the value required to use variable in mqtt topic. Required for Sensor setup.
MQTT username. Defaults to !secret mqtt_user if blank! Required for Sensor setup.
MQTT_Pass:
name: MQTT Pass
name: MQTT Pass !secret mqtt_pass is default!
description: >-
"$MQTT_Pass" is the value required to use variable in mqtt topic. Required for Sensor setup.
MQTT password. Defaults to !secret mqtt_pass if blank! Required for Sensor setup.
MQTT_Topic:
name: MQTT Topic
name: MQTT Topic Leave as default for sensors!
description: >-
homeassistant/sbfspot_{plantname}/sbfspot_{serial} is default. {plantname} and {serial} are captured variables.
MQTT_ItemFormat:
name: MQTT json globbing style
description: >-
'"{key}": {value}' is default.
'"{key}": {value}' is default. Leave blank for default!
MQTT_ItemDelimiter:
name: MQTT json separator
description: >-
comma is default.
MQTT_PublisherArgs:
name: MQTT Publisher args. ADD MQTT user and pass
name: MQTT_PublisherArgs - - Option removed to allow Sensor set up. Add MQTT_User and MQTT_Pass to respective options.
description: >-
-h {host} -u "$MQTT_User" -P "$MQTT_Pass" -t {topic} -m "{{message}}" -d Leave the "$variables" to use options or add user & pass. -d is debug
Option removed to allow Sensor set up. Add MQTT_User and MQTT_Pass to respective options.
MQTT_Data:
name: MQTT sensors items.
name: MQTT Sensors items. Add or remove desired options. The list be found in SBFspot.default.cfg or the readme.
description: >-
Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvSwVer,InvStatus,InvTemperature,InvGridRelay,EToday,ETotal,GridFreq,PACTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,PDCTot,OperTm,FeedTm,BTsignal is default
Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvSwVer,InvClass,InvType,InvTemperature,OperTm,FeedTm,EToday,ETotal,GridFreq,PACTot,PAC1,UAC1,IAC1,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,BTSignal is default
PVoutput_SID:
name: PVoutput SID
name: PVoutput SID !secret pvoSID
description: >-
Add your Inverter serial number and PVoutput API id here. Can be fake if you don't want to create an account.
Add your Inverter serial number and PVoutput API id here. Inverter serial > 0123456789:12345 < PVoutput ID
PVoutput_Key:
name: PVoutput API key
name: PVoutput API key !secret pvoAPIkey
description: >-
Add you PVoutput API key here. Can be fake if you don't want to create an account.
Add you PVoutput API key here. Defaults to fake if you don't want to create an account.
LogDir:
name: PVoutput Upload logs
name: PVoutput Upload logs. This option is defunct. Removed in SBFspot 3.9.6
description: >-
/data/sbfspot/log/ is Default. These logs are deleted after 3 days as long as the default path is used.
Removed in SBFspot 3.9.6
LogLevel:
name: PVoutput upload logs level
description: >-