Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull-Request as Delta #7

Open
wants to merge 39 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6c483ce
Initial work for AP Systems
csowada Mar 3, 2021
362394a
Update README_AP_SYSTEMS_ZIGBEE.md
csowada Mar 4, 2021
df25c47
First PoC for APS parser version with MQTT
csowada Mar 7, 2021
101f278
Merge branch 'aps-pv-ecu' of https://github.com/csowada/Tasmota into …
csowada Mar 7, 2021
2113cd7
fix calculations
csowada Mar 8, 2021
cc0fa65
Add QS1 inverter, enhance calculations
csowada Mar 9, 2021
23b41b8
Add platformio env zbapsystems
csowada Mar 9, 2021
70fda69
update git action, add esp32 build
csowada Mar 9, 2021
0886a62
Set IEEE address with ExtPanID
csowada Mar 10, 2021
ff534cf
Add Z_APSystems device and parser
csowada Mar 13, 2021
cc5821a
Cleanup code and use ifdef for apsystems
csowada Mar 13, 2021
387d0e0
Change parser to macros
csowada Mar 13, 2021
c6aff2e
Fix temperature value
csowada Mar 13, 2021
46168d8
Add missing powerl calculation in Wh
csowada Mar 13, 2021
c99f9b6
Fixed Power calculation
csowada Mar 14, 2021
25e9f29
Remove some debug changes
csowada Mar 15, 2021
4434da5
Add voltage and calc. Power
csowada Mar 17, 2021
d9455b2
Fix reboot issue due to wrong log type
csowada Mar 20, 2021
e04500c
Add Tasmota Energy Monitor feature
csowada Mar 20, 2021
8082030
Remove IEEE Adress getter and setter
csowada Mar 21, 2021
228956d
Add active power for channels
csowada Mar 21, 2021
8803bdc
Add 5mins timeout for Inverter responses
csowada Mar 22, 2021
bd45837
Move all to new main file, add ZbQueryInvert Cmd
csowada Mar 22, 2021
9f412c2
Cleanup after main file move
csowada Mar 22, 2021
d5b01e4
Rename 3ch enery meter device
csowada Mar 22, 2021
b8e97b6
more vars renamed for 4-channel meter
csowada Mar 22, 2021
9f223aa
Allow unknown addr for QueryInverter Cmnd
csowada Mar 22, 2021
605923a
Add example for faster polling with new Cmnd
csowada Mar 22, 2021
a85942e
Fix timeout, more validations
csowada Mar 28, 2021
4ff8722
Fix kWh total calulcation
csowada Mar 28, 2021
c5c7fb7
Change TotalPower to TotalEnergy
csowada Mar 28, 2021
55059ca
Rename TodayN to TodayEneergyN
csowada Mar 28, 2021
4b9368c
Add TodayEnergy per Inverter
csowada Mar 28, 2021
b1926c2
Fix power calculation
csowada Mar 29, 2021
4a5ddb3
Update current and voltage calculations
csowada Mar 29, 2021
8760855
Add new todayEnergy variant for test
csowada Mar 29, 2021
4437ef2
Fix energy meter reference issue
csowada Mar 29, 2021
3f77604
Fix 24h today total
csowada Mar 30, 2021
ba3b331
Fix midnight reset issue
csowada Apr 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,233 changes: 626 additions & 607 deletions .github/workflows/CI_github.yml

Large diffs are not rendered by default.

1,378 changes: 699 additions & 679 deletions .github/workflows/CI_github_ESP32.yml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions .github/workflows/Tasmota_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,24 @@ jobs:
name: firmware
path: ./build_output

tasmota-zbapsystems:
needs: tasmota_pull
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
- name: Install dependencies
run: |
pip install -U platformio
- name: Run PlatformIO
run: |
platformio run -e tasmota-zbapsystems
- uses: actions/upload-artifact@v2
with:
name: firmware
path: ./build_output

tasmota-AF:
needs: tasmota_pull
Expand Down
68 changes: 68 additions & 0 deletions README_AP_SYSTEMS_ZIGBEE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

## Todos

- IEEE is hardcoded to 0xD8A3011B97xx
- Unable to change channel (use firmware with channel 16 as default)
- Encode polled data into values
- Allow to set ECU ID

## Already included

- AP System profile and Endpoint registered
- IEEE adress set
- Excluded security stuff if firmware is without SECURE compiled

## My Example Setup

- ECU ID: ``0xD8A3FFFF823D0910``
- Inverter ID: ``0x3D82``

## Configurate Tasmota

- Build Tasmota with Zigbee and ZNP Support
- Connect CC2530 with ESP8266
- VCC -> VCC
- GND -> 3.3V
- P02 -> D8
- P03 -> D7
- Configurate the Module
- Select Generic (0)
- D7/GPIO13 = Zigbee RX
- D8/GPIO15 = Zigbee TX
- Check if Zigbee is started, use Sniffer and click ``Zigbee Permit Join`` button for test
- Submit command via Web console (Pan ID are the first two IEEE bytes)
```
ZbConfig {"Channel":16,"PanID":"0xA3D8","ExtPanID":"0xD8A3FFFF823D0910"}
ZbReset 1 (required?)
```

#### Send to broadcast to all inverters
Submit command via Web console
```
ZbZNPSend 2401FFFF1414060000000F1E80971B01A3D8FBFB1100000D6030FBD3000000000000000004010281FEFE
```

#### Send request to inverter 0x3D82
Submit command via Web console
```
ZbZNPSend 2401823D1414060001000F1380971B01A3D8FBFB06BB000000000000C1FEFE
```

## Rules

Use rules to poll the invertes every minute

```
Rule1
ON Time#Minute DO ZbZNPSend 2401823D1414060001000F1380971B01A3D8FBFB06BB000000000000C1FEFE ENDON

Rule1 1
```

or

```
Rule1 ON System#Boot DO RuleTimer1 20 ENDON ON Rules#Timer=1 DO backlog ZbQueryInverter 0x3d82; RuleTimer1 20 ENDON

Rule1 1
```
4 changes: 4 additions & 0 deletions platformio_tasmota_env.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ board_build.ldscript = eagle.flash.2m256.ld
board_build.f_cpu = 160000000L
lib_extra_dirs = lib/lib_ssl

[env:tasmota-zbapsystems]
build_flags = ${common.build_flags} -DUSE_ZIGBEE -DUSE_ZIGBEE_ZNP -DUSE_ZIGBEE_DISABLED_SECURITY -DUSE_AP_SYSTEMS -DUSE_ENERGY_SENSOR
board_build.ldscript = eagle.flash.4m2m.ld

[env:tasmota-AF]
build_flags = ${common.build_flags} -DMY_LANGUAGE=af_AF

Expand Down
4 changes: 4 additions & 0 deletions platformio_tasmota_env32.ini
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ lib_extra_dirs = lib/libesp32, lib/lib_basic
extends = env:tasmota32
build_flags = ${common32.build_flags} ${irremoteesp_full.build_flags} -DFIRMWARE_IR_CUSTOM

[env:tasmota32-zbapsystems]
extends = env:tasmota32
build_flags = ${common32.build_flags} -DUSE_ZIGBEE -DUSE_ZIGBEE_ZNP -DUSE_ZIGBEE_DISABLED_SECURITY -DUSE_AP_SYSTEMS

[env:tasmota32-AF]
extends = env:tasmota32
build_flags = ${common32.build_flags} -DMY_LANGUAGE=af_AF
Expand Down
5 changes: 5 additions & 0 deletions tasmota/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@
#define D_CMND_ZIGBEE_SCAN "Scan"
#define D_JSON_ZIGBEE_SCAN "ZbScan"

#ifdef USE_AP_SYSTEMS
#define D_CMND_ZIGBEE_QUERY_INVERTER "QueryInverter"
#define D_JSON_ZIGBEE_QUERY_INVERTER "ZbQueryInverter"
#endif

// Commands xdrv_25_A4988_Stepper.ino
#define D_CMND_MOTOR "MOTOR"
#define D_JSON_MOTOR_MOVE "doMove"
Expand Down
2 changes: 2 additions & 0 deletions tasmota/xdrv_23_zigbee_0_constants.ino
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,8 @@ enum Z_App_Profiles {
Z_PROF_TA = 0x0107, // Telecom Applications
Z_PROF_PHHC = 0x0108, // Personal Home & Hospital Care
Z_PROF_AMI = 0x0109, // Advanced Metering Initiative

Z_PROF_AP_SYSTEMS = 0x0F05, // APS PV Module // custom
};

enum Z_Device_Ids {
Expand Down
55 changes: 53 additions & 2 deletions tasmota/xdrv_23_zigbee_2_devices.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum class Z_Data_Type : uint8_t {
Z_Alarm = 4,
Z_Thermo = 5, // Thermostat and sensor for home environment (temp, himudity, pressure)
Z_OnOff = 6, // OnOff, Buttons and Relays (always complements Lights and Plugs)
Z_4Ch_EnergyMeter = 7, // 4-channel enery meter
Z_Mode = 0xE, // Encode special modes for communication, like Tuya Zigbee protocol
Z_Ext = 0xF, // extended for other values
Z_Device = 0xFF // special value when parsing Device level attributes
Expand All @@ -45,7 +46,7 @@ const uint8_t Z_Data_Type_char[] PROGMEM = {
'A', // 0x04 Z_Data_Type::Z_Alarm
'T', // 0x05 Z_Data_Type::Z_Thermo
'O', // 0x06 Z_Data_Type::Z_OnOff
'\0', // 0x07
'V', // 0x07 Z_Data_Type::Z_4Ch_EnergyMeter
'\0', // 0x08
'\0', // 0x09
'\0', // 0x0A
Expand Down Expand Up @@ -170,6 +171,53 @@ public:
uint8_t power;
};


/*********************************************************************************************\
* Device specific: 4-Channel Energy Meter
\*********************************************************************************************/
class Z_Data_4Ch_EnergyMeter : public Z_Data {
public:
Z_Data_4Ch_EnergyMeter(uint8_t endpoint = 0) :
Z_Data(Z_Data_Type::Z_4Ch_EnergyMeter, endpoint),
time_stamp(0xFFFF),
total_energy1(0xFFFFFFFF),
total_energy2(0xFFFFFFFF),
total_energy3(0xFFFFFFFF),
total_energy4(0xFFFFFFFF)
{}

inline bool validTimeStamp(void) const { return 0xFFFF != time_stamp; }
inline bool validTotalEnergy1(void) const { return 0xFFFFFFFF != total_energy1; }
inline bool validTotalEnergy2(void) const { return 0xFFFFFFFF != total_energy2; }
inline bool validTotalEnergy3(void) const { return 0xFFFFFFFF != total_energy3; }
inline bool validTotalEnergy4(void) const { return 0xFFFFFFFF != total_energy4; }

inline uint16_t getTimeStamp(void) const { return time_stamp; }
inline uint32_t getTotalEnergy1(void) const { return total_energy1; }
inline uint32_t getTotalEnergy2(void) const { return total_energy2; }
inline uint32_t getTotalEnergy3(void) const { return total_energy3; }
inline uint32_t getTotalEnergy4(void) const { return total_energy4; }

inline void setTimeStamp(uint16_t _time_stamp) { time_stamp = _time_stamp; }
inline void setTotalEnergy1(uint32_t _total_energy1) { total_energy1 = _total_energy1; }
inline void setTotalEnergy2(uint32_t _total_energy2) { total_energy2 = _total_energy2; }
inline void setTotalEnergy3(uint32_t _total_energy3) { total_energy3 = _total_energy3; }
inline void setTotalEnergy4(uint32_t _total_energy4) { total_energy4 = _total_energy4; }

inline void addTotalEnergy1(uint32_t _total_energy1) { if (validTotalEnergy1()) {total_energy1 += _total_energy1; } else {total_energy1 = _total_energy1; } }
inline void addTotalEnergy2(uint32_t _total_energy2) { if (validTotalEnergy2()) {total_energy2 += _total_energy2; } else {total_energy2 = _total_energy2; } }
inline void addTotalEnergy3(uint32_t _total_energy3) { if (validTotalEnergy3()) {total_energy3 += _total_energy3; } else {total_energy3 = _total_energy3; } }
inline void addTotalEnergy4(uint32_t _total_energy4) { if (validTotalEnergy4()) {total_energy4 += _total_energy4; } else {total_energy4 = _total_energy4; } }

static const Z_Data_Type type = Z_Data_Type::Z_4Ch_EnergyMeter;

uint16_t time_stamp;
uint32_t total_energy1;
uint32_t total_energy2;
uint32_t total_energy3;
uint32_t total_energy4;
};

/*********************************************************************************************\
* Device specific: Plug device
\*********************************************************************************************/
Expand Down Expand Up @@ -539,7 +587,7 @@ const uint8_t Z_Data_Type_len[] PROGMEM = {
sizeof(Z_Data_Alarm), // 0x04 Z_Data_Type::Z_Alarm
sizeof(Z_Data_Thermo), // 0x05 Z_Data_Type::Z_Thermo
sizeof(Z_Data_OnOff), // 0x06 Z_Data_Type::Z_OnOff
0, // 0x07
sizeof(Z_Data_4Ch_EnergyMeter), // 0x07 Z_Data_Type::Z_4Ch_EnergyMeter
0, // 0x08
0, // 0x09
0, // 0x0A
Expand Down Expand Up @@ -600,6 +648,7 @@ bool Z_Data_Set::updateData(Z_Data & elt) {
case Z_Data_Type::Z_Alarm: return ((Z_Data_Alarm&) elt).update(); break;
case Z_Data_Type::Z_Thermo: return ((Z_Data_Thermo&) elt).update(); break;
case Z_Data_Type::Z_OnOff: return ((Z_Data_OnOff&) elt).update(); break;
case Z_Data_Type::Z_4Ch_EnergyMeter: return ((Z_Data_4Ch_EnergyMeter&) elt).update(); break;
case Z_Data_Type::Z_PIR: return ((Z_Data_PIR&) elt).update(); break;
case Z_Data_Type::Z_Mode: return ((Z_Data_Mode&) elt).update(); break;
default: return false;
Expand All @@ -618,6 +667,8 @@ Z_Data & Z_Data_Set::getByType(Z_Data_Type type, uint8_t ep) {
return get<Z_Data_Thermo>(ep);
case Z_Data_Type::Z_OnOff:
return get<Z_Data_OnOff>(ep);
case Z_Data_Type::Z_4Ch_EnergyMeter:
return get<Z_Data_4Ch_EnergyMeter>(ep);
case Z_Data_Type::Z_PIR:
return get<Z_Data_PIR>(ep);
case Z_Data_Type::Z_Mode:
Expand Down
5 changes: 5 additions & 0 deletions tasmota/xdrv_23_zigbee_5_converters.ino
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ public:
return _frame_control.b.frame_type & 1;
}

#ifdef USE_AP_SYSTEMS
// parse photovoltaics messages from AP Systems
void parseAPSAttributes(Z_attribute_list& attr_list);
#endif

void parseReportAttributes(Z_attribute_list& attr_list);
void generateSyntheticAttributes(Z_attribute_list& attr_list);
void removeInvalidAttributes(Z_attribute_list& attr_list);
Expand Down
Loading
Loading