master c36009e5c171 cached
15 files
77.4 KB
17.9k tokens
39 symbols
1 requests
Download .txt
Repository: Hypfer/deye-microinverter-cloud-free
Branch: master
Commit: c36009e5c171
Files: 15
Total size: 77.4 KB

Directory structure:
gitextract_nannntza/

├── .gitignore
├── Readme.md
├── assets/
│   └── deye_sun600.ksy
└── dummycloud/
    ├── .automated.eslintrc.json
    ├── .eslintrc.json
    ├── Dockerfile
    ├── LICENSE
    ├── Readme.md
    ├── app.js
    ├── package.json
    └── src/
        ├── DummyCloud.js
        ├── Logger.js
        ├── MqttClient.js
        ├── Protocol.js
        └── util.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
/dummycloud/node_modules/


================================================
FILE: Readme.md
================================================
# Deye Microinverter - Cloud-free

![Deye microinverter in the sun](img/banner.jpg)

Solar power generation work best if there are no clouds anywhere to be seen :)
<br/><br/>

This repository aims to document how to use Deye microinverters entirely local only and cloud free.
It consolidates the knowledge that at the time of writing was spread over hundreds of different posts, issues and comments.

Furthermore, it also features a cloud replacement implementation so you won't have to install any apps or create any accounts.
You also won't have to share any e-mail address or phone number.

## Devices

So far, the following devices are known to work like this:

- Deye SUN600G3-EU-230
- Deye SUN-M80G3-EU-Q0
- Deye SUN-M80G4-EU-Q0

it should also be the same for other inverters of the same series including rebrands such as Bosswerk.<br/>
If you have verified that it works with another device, feel free to extend this list.

## TL;DR

Here are the main things you will want to know about these microinverters:

- They have Wi-Fi
- They can be connected to Wi-Fi networks via their webinterface
- They can operate without an internet connection
- They can operate without an account
- They can be monitored and controlled via their local ModbusTCP interface
- You can also completely replace the cloud with a local implementation: [dummycloud](./dummycloud)

**2024-08-20 Update**

Deye has started rolling out firmware updates for the logger that block both ModbusTCP access and prevent the mock cloud
from working due to the introduction of TLS. Fortunately, for now it seems that newly bought inverters still come with older
logger firmwares that work offline.
Also equally fortunately, it seems that downgrading the firmware is possible as well.

However, both of these things may change in the future.

## Preamble

Compared to traditional PV setups where a single large inverter is connected to strings of many PV Panels, in a microinverter Setup, you have one small inverter for every 1-4 PV Panels.

There are up- and downsides to both of these topologies but that is for now out of scope for this document.
What you need to know is that microinverters are cheaper and scaled-down versions of their larger brothers.

Because they only cost 150-200€ they make getting into solar power generation accessible for many more people than ever before.
Paired with two PV Panels you're looking at an investment of at most 1000€ to get free energy from the sun.

Additionally, because you only need few panels for the setup to make sense financially, often a balcony or garden can be enough for a small solar setup.
This is especially interesting for people living in rental properties.

### Word of warning

After reading through way too many concerning posts and comments, here's what has to be said:

**Please** please please don't cut any corners when it comes to safety-critical stuff such as cabling and also mounting panels.
You don't want your home to burn down or anyone to be killed by a falling 1.5m² 25kg PV Panel.

Electricity is dangerous. So are heavy things with a huge attack surface for wind.<br/>
When in doubt, contact a local electrician. They know what they're doing and will help you.

## Setup

Now with that out of the way, we can talk about what to do.

The first important thing to note is that these inverters will shut down if they don't sense at least 20V on at least one PV input.
This means that you have to do all this during the day connected while connected to a PV panel.

Alternatively, some people reported that they got the inverter to wake up by connecting a 30V lab power supply to one of the PV inputs.

### Joining Wi-Fi

By default, your microinverter should provide a Wi-Fi Access point with an SSID named similarly to `AP_4151234567`.
Using a laptop, connect to that using the password printed on the AP or for older inverters the default password `12345678`.

In a browser, navigate to the IP of the inverter in that network which should by default be `http://10.10.100.254/`.
Log in to the webinterface with the default credentials `admin:admin` and use that to configure Wi-Fi.

![wifi configuration](img/wifi_config.png)

The AP-mode can be a bit unstable so prepare for the webinterface stopping to work occasionally.
Once the inverter is connected to you Wi-Fi, this should not be an issue anymore.


### Ensuring a patched logger firmware

After joining the inverter to you Wi-Fi network, connect to the webinterface again but this time using the IP in your network.

Now, expand the `Device Information` on the `Status` page and ensure that your logger firmware version is at least `MW3_16U_5406_1.53` or newer.

![firmware version](img/firmware_version.png)

Older firmwares don't allow reconfiguration of the Wi-Fi AP, which is a serious vulnerability, as it allows an attacker to easily gain access to your real Wi-Fi credentials.

If your firmware is older, you can find firmware update files in this repo: [https://github.com/dasrecht/deye-firmware](https://github.com/dasrecht/deye-firmware).
You can flash them using the `Upgrade Firmware` page of the webinterface.


### Securing the AP

With the logger firmware upgraded, you should now use the webinterface to change SSID and Password for the AP of the inverter.

![ap config](img/ap_config.png)

Pick something not immediately obvious and relatively secure as - as mentioned before - it is all that prevents an attacker from connecting to that AP and reading out your main Wi-Fi credentials.

I have been told that you can also use the wizard to disable the AP entirely, however personally, I like having a fallback way into the inverter, especially since I did not see a "Factory Reset" button on the device.


### Configuring your network

Now that the AP is secured, use the configuration interface of your router to block internet access of the inverter.
You will also likely want to configure it, so that it will always get the same IP assigned via DHCP.

These things should be dropdowns and checkboxes in most consumer routers.
If you run some advanced setup, you will know what to do.

You can also try to DNS-block `access1.solarmanpv.com` and `access2.solarmanpv.com`, however it seems that the logger firmware might also use hardcoded IPs?
Either way, just blocking internet access entirely should be much easier in most setups anyway and comes with no known downsides.

## Usage

After connecting the inverter to your Wi-Fi network, securing it and blocking its internet access, all you need to do now is monitor and control it.

For this there are different options.

### Local polling
Most of the options rely on polling the local modbusTCP interface that uses the inverter logger serial number for authentication.

To get this serial, simply look at the sticker on the device:

![logger_serial_number](img/logger_sn.png)

If you feel like doing something arcane and/or want to build something for that yourself, you can find the Modbus spec for these inverters in the complementary assets repo:
[https://github.com/Hypfer/deye-microinverter-cloud-free-assets](https://github.com/Hypfer/deye-microinverter-cloud-free-assets).

Note that with internet access blocked, the inverter never receives any time information.
This breaks the `Yield today` counter as it will never properly reset unless you manually set the time on each boot using modbus register `22`, `23` and `24`.


#### With Home Assistant

With Home Assistant, the easiest way to get your inverter connected is by using [HACS](https://hacs.xyz/) to install the [Solarman](https://github.com/StephanJoubert/home_assistant_solarman) `custom_component`.
Please refer to the project documentation on how to install and configure those.

Home Assistant offers powerful tooling to store, visualize and process data right out of the box.

For example, here's how a solar dashboard could look like using mock data and only stock home assistant cards.
The real world will obviously look slightly different but the idea should be the same:

![example home assistant dashboard](img/dashboard_example_mock.png)


#### With other smarthome software

If you're using OpenHAB, FHEM, ioBroker or something else, as long as it can speak MQTT, you can use for example [https://github.com/kbialek/deye-inverter-mqtt](https://github.com/kbialek/deye-inverter-mqtt) to connect your inverter to your smarthome.

A `docker-compose.yml` entry for that tool could look like this:

```yaml
  deyetomqtt:
    image: ghcr.io/kbialek/deye-inverter-mqtt
    container_name: "deyetomqtt"
    environment:
      - LOG_LEVEL=DEBUG
      - DEYE_DATA_READ_INTERVAL=60
      - DEYE_METRIC_GROUPS=micro
      - DEYE_LOGGER_SERIAL_NUMBER=4151234567
      - DEYE_LOGGER_IP_ADDRESS=192.168.178.123
      - DEYE_LOGGER_PORT=8899
      - MQTT_HOST=192.168.178.2
      - MQTT_TOPIC_PREFIX=deye
      - MQTT_PORT=1883
    restart: always
```

Keep in mind that this might change in the future so make sure to always check the docs of the project itself.

### Using the dummycloud

If you don't want polling and/or are unhappy with having the inverter in a perpetual state of reconnection to the cloud,
you can instead deploy the cloud replacement that can be found in the [dummycloud](./dummycloud) folder in this repository.

This will make the inverter happy, provide it with the correct time for daily counters to work and push all the data to your MQTT broker.
It will also autoconfigure entities for home assistant.

![dummycloud_demo.png](./img/dummycloud_demo.png)

It is however a bit more complicated than the polling approaches, as it requires you to understand how networks work
and how to deploy a service somewhere. Nothing too arcane of course but if you don't know anything about linux, you might want to pass on this.

For further information, check out the [dummycloud](./dummycloud) folder.

## Misc

### Hidden configuration page

These inverters also have a hidden configuration page that is reachable via `/config_hide.html`.

There, it is possible to configure

- Cloud Server A and B
- Serial Port parameters (which serial port?)
- The port of the modbusTCP server of the inverter
- Enable/Disable the AP
- Switch the branding(?)

<details>
<summary>Click here to show a screenshot of the page</summary>

![config hide screenshot](img/config_hide.png)

</details>

### AT Commands

Apart from the modbus over tcp interface, these inverters also provide another interface on port 48899 where you can talk to it over AT commands like a modem.
For that, for now you can use this tool: [https://github.com/s10l/deye-logger-at-cmd](https://github.com/s10l/deye-logger-at-cmd).

Some firmware versions seem to respond to the `AT+H` command with a full list of commands.
Mine doesn't, however a [user fortunately posted a full response](https://www.photovoltaikforum.com/thread/180129-deye-sun600-und-sun2000-erfahrungen/?postID=2846951#post2846951) which is the source for this table:

<details>
<summary>Click here to show the AT command table</summary>

| Command                                   | Vendor Description                                      |
|-------------------------------------------|---------------------------------------------------------|
| AT+TIME                                   | Set/Get Device Time                                     |
| AT+ADDRESS                                | Set/Get Device Address                                  |
| AT+KEY                                    | Set/Get Device Password                                 |
| AT+MTYPE                                  | Set/Get Device Mtype                                    |
| AT+CNMOSAVE                               | Set/Get TCPB Link Mode                                  |
| AT+DEVICENUM                              | Set/Get Device Link Num                                 |
| AT+DEVSELCTL                              | Set/Get Web Device List Info                            |
| AT+NDBGS                                  | Set/Get Debug Status                                    |
| AT+FFCLER                                 | Clear File in Flash                                     |
| AT+LANGSEL                                | Select Language                                         |
| AT+ADTIME                                 | Set/Get Device Time                                     |
| AT+YZFTIME                                | Set/Get Device factory Time                             |
| AT+TZEARSE                                | Clear yz File in Flash                                  |
| AT+YZACK                                  | Clear yz File in Flash                                  |
| AT+YZTIME                                 | Clear yz File in Flash                                  |
| AT+YZWKTIME                               | Clear yz File in Flash                                  |
| AT+YZERRCLR                               | Clear yz File in Flash                                  |
| AT+YZDBNUM                                | Clear yz File in Flash                                  |
| AT+YZDB                                   | Clear yz File in Flash                                  |
| AT+YZVER                                  | Clear yz File in Flash                                  |
| AT+YZLOG                                  | Clear yz File in Flash                                  |
| AT+YZAPP                                  | Clear yz File in Flash                                  |
| AT+YZAPSTAT                               | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZWAKEYCTL                             | Clear yz File in Flash                                  |
| AT+YZsize                                 | Clear yz File in Flash                                  |
| AT+YZFLSHTEST=<password>,<devlist_status> |                                                         |
| AT+YZFLSHTEST=<password>,<devlist_status> |                                                         |
| AT+YZVER                                  | Clear yz File in Flash                                  |
| AT+YZVER                                  | Clear yz File in Flash                                  |
| AT+YZVER                                  | Clear yz File in Flash                                  |
| AT+YZVER                                  | Clear yz File in Flash                                  |
| AT+YZVER                                  | Clear yz File in Flash                                  |
| AT+YZEXPFUN                               | Clear yz File in Flash                                  |
| AT+YZEXPFUN                               | Clear yz File in Flash                                  |
| AT+YZEXPFUN                               | Clear yz File in Flash                                  |
| AT+YZEXPFUN                               | Clear yz File in Flash                                  |
| AT+YZEXPFUN                               | Clear yz File in Flash                                  |
| AT+YZEXPFUN                               | Clear yz File in Flash                                  |
| AT+TMODE                                  | Set/Get the UART work mode.                             |
| AT+ENTM                                   | Goto Through MOde.                                      |
| AT+UART                                   | Set/Get the UART0/UART1 Parameters.                     |
| AT+WSMAC                                  | Set/Get Module MAC Address.                             |
| AT+WAMAC                                  | Get Module MAC Address in AP mode.                      |
| AT+NDBGL                                  | set/get debug level                                     |
| AT+RELD                                   | Reload the default setting and reboot.                  |
| AT+RLDEN                                  | Put on/off the Reload Pin.                              |
| AT+MID                                    | Get The Module ID.                                      |
| AT+WRMID                                  | Write Module ID.                                        |
| AT+ASWD                                   | Set/Query WiFi configuration code.                      |
| AT+VER                                    | Get application version.                                |
| AT+BVER                                   | Get bootloader version.                                 |
| AT+HWVER                                  | Get hardware version.                                   |
| AT+FCLR                                   | Clear Fsetting.                                         |
| AT+CFGRD                                  | Get current system config.                              |
| AT+CFGTF                                  | Save Current Config to Default Config.                  |
| AT+SMEM                                   | show system memory stat                                 |
| AT+OTA                                    | OTA                                                     |
| AT+UPURL                                  | Set/Get the path of remote upgrade.                     |
| AT+CMDPW                                  | Set/Get cmd password in throuphput mode.                |
| AT+UID                                    | Set/Get UID.                                            |
| AT+E                                      | Echo ON/Off, to turn on/off command line echo function. |
| AT+Z                                      | Reset the Module.                                       |
| AT+SRST                                   | Soft Reset the Module.                                  |
| AT+H                                      | show help                                               |
| AT+NETP                                   | Set/Get the Net Protocol Parameters.                    |
| AT+TCPLK                                  | Get The state of TCP link.                              |
| AT+TCPTO                                  | Set/Get TCP time out.                                   |
| AT+TCPDIS                                 | Connect/Dis-connect the TCP Client link                 |
| AT+MAXSK                                  | Set/Get MAX num of TCP socket (1~5)                     |
| AT+RCV                                    | Recv data from socket_a                                 |
| AT+SEND                                   | Send data to socket_a                                   |
| AT+SOCKB                                  | Set/Get Parameters of socket_b.                         |
| AT+TCPLKB                                 | Get The state of TCP_B link.                            |
| AT+TCPTOB                                 | Set/Get TCP_B time out.                                 |
| AT+TCPDISB                                | Connect/Dis-connect the TCP_B Client link.              |
| AT+RCVB                                   | Recv data from socket_b                                 |
| AT+SNDB                                   | Send data to socket_b                                   |
| AT+WMODE                                  | Set/Get the WIFI Operation Mode (AP or STA).            |
| AT+WSSSID                                 | Set/Get the AP's SSID of WIFI STA Mode.                 |
| AT+WSKEY                                  | Set/Get the Security Parameters of WIFI STA Mode.       |
| AT+WSLK                                   | Get Link Status of the Module (Only for STA Mode).      |
| AT+WSLQ                                   | Get Link Quality of the Module (Only for STA Mode).     |
| AT+WAP                                    | Set/Get the AP parameters.                              |
| AT+WAKEY                                  | Set/Get the Security Parameters of WIFI AP Mode.        |
| AT+WALK                                   | Show sta information of AP connection.                  |
| AT+WALKIND                                | enable/disable LED indication of AP connection.         |
| AT+WAPMXSTA                               | Set/Get the Max Number Of Sta Connected to Ap.          |
| AT+WSCAN                                  | Get The AP site Survey (only for STA Mode).             |
| AT+SMTLK                                  | Start Smart Configuration.                              |
| AT+SMTLKST=mode,protocol                  | Setup smartlnk mode and protocol.                       |
| AT+SMARTAPCONFIG                          | Enable/disable smart AP config function.                |
| AT+SMARTAPSTART                           | Start smart AP config function.                         |
| AT+WPS                                    | Start WPS.                                              |
| AT+DISPS                                  | Disable power saving mode of WIFI                       |
| AT+WIFI=UP/DOWN                           | Power down or up  the wifi chip.                        |
| AT+MDCH                                   | Put on/off automatic switching WIFI mode.               |
| AT+WSLKO                                  | Enable/Disable connect router with the best signal.     |
| AT+DTIM                                   | Set/Get station listen interval(1~3).                   |
| AT+UDPLCPT                                | Set/Get local UDP port.                                 |
| AT+PING                                   | General PING command.                                   |
| AT+WANN                                   | Set/Get The WAN setting if in STA mode.                 |
| AT+LANN                                   | Set/Get The LAN setting if in ADHOC mode.               |
| AT+WADHCP                                 | enable/disable AP dhcp server and set ip address pool   |
| AT+WEBU                                   | Set/Get the Login Parameters of WEB page.               |
| AT+WEBVER                                 | Get WEB version.                                        |
| AT+PLANG=EN/CN                            | Set/Get the language of WEB page.                       |
| AT+WSDNS                                  | Set/Get the DNS Server address.                         |
| AT+NTPEN                                  | Enable/Disable NTP Server.                              |
| AT+NTPRF                                  | Set/Query NTP.                                          |
| AT+NTPTM                                  | Set/Query Ntp Time.                                     |
| AT+NTPSER                                 | Set/Query Ntp Server.                                   |
| AT+TXPWR                                  | Set/Get wifi rf tx power.                               |
| AT+RFTESTMODE                             | RF test mode ON/OFF.                                    |

</details>


## Donate

If this software and documentation effort brought value to you, there's the option to leave a small donation using the "Sponsor" button on top of the repo or by [clicking right here](https://github.com/sponsors/Hypfer).

Thanks!


================================================
FILE: assets/deye_sun600.ksy
================================================
meta:
  id: deye_sun600

seq:
  - id: header
    type: header
  - id: payload
    size: header.payload_length
    type:
      switch-on: header.msg_type
      cases:
        "msg_type::handshake": handshake_msg_payload
        "msg_type::data": data_msg_payload
        "msg_type::wifi": wifi_msg_payload
        "msg_type::command": command_msg_payload
  - id: footer
    type: footer

types:
  header:
    seq:
      - id: magic
        contents: [0xa5]
      - id: payload_length
        type: u2le
      - id: unknown1
        type: u1
      - id: msg_type
        type: u1
        enum: msg_type
      - id: msg_id_response
        type: u1
      - id: msg_id_request
        type: u1
      - id: logger_sn
        type: u4le
  footer:
    seq:
      - id: checksum
        type: u1
      - id: magic
        contents: [0x15]
  
  command_msg_payload:
    seq:
      - size: 15
      - id: command
        type: str
        encoding: ASCII
        size-eos: true
  
  handshake_msg_payload:
    seq:
      - size: 13
      - size: 6
      - id: fw_ver
        type: str
        size: 40
        encoding: ASCII
      - size: 6
      - id: ip
        type: str
        size: 16
        encoding: ASCII
      - size: 8
      - id: version
        type: str
        size: 18
        encoding: ASCII
      - size: 65
      - id: ssid
        type: str
        size: 30
        encoding: ASCII
      - id: unknown
        size-eos: true

  data_msg_payload:
    seq:
      - id: payload_magic # Might be destination? 01 for logger, 02 for inverter, 129 for logger historic
        size: 1 # has to be carried over to the response
      - id: schema
        enum: data_msg_payload_schema
        type: u1
      - id: data
        size-eos: true
        type:
          switch-on: schema
          cases:
            "data_msg_payload_schema::microinverter": data_msg_payload_microinverter
            "data_msg_payload_schema::hybridinverter": data_msg_payload_hybridinverter
  
  data_msg_payload_hybridinverter:
    seq:
      - size: 1
      - id: unknown
        type: u4le
      - id: power_on_time
        type: u4le
      - id: unknown2
        type: u4le
      - size: 10
      - id: inverter_serial
        type: str
        size: 10
        encoding: ASCII
      - size: 6
      - id: some_string
        type: str
        size: 28
        encoding: ASCII
      - size: 26
      - id: energy_battery_charge_today
        type: s2be
      - id: energy_battery_discharge_today
        type: s2be
      - id: energy_battery_charge_total
        type: s4be
      - id: energy_battery_discharge_total
        type: s4be
      - id: energy_grid_import_today
        type: s2be
      - id: energy_grid_export_today
        type: s2be
      - id: energy_grid_import_total
        type: s4be
      - id: energy_grid_export_total
        type: s4be
      - id: energy_house_today
        type: s2be
      - id: energy_house_total
        type: s4be

      - size: 4

      - id: energy_pv_today
        type: s2be
      - id: energy_pv1_today # TODO
        type: s2be
      - id: energy_pv2_today # TODO
        type: s2be
      - id: energy_pv_total
        type: s4be

      - size: 34

      - id: battery_temp
        type: s2be
      - id: battery_voltage
        type: s2be
      - id: battery_soc_pct
        type: s2be
      - size: 2
      - id: battery_power
        type: s2be
      - id: battery_current
        type: s2be
      - id: battery_unknown 
        type: s2be

      - id: grid_l1_n_voltage
        type: s2be
      - id: grid_l2_n_voltage
        type: s2be
      - id: grid_l3_n_voltage
        type: s2be

      - size: 8

      - id: grid_l1_power
        type: s2be
      - id: grid_l2_power
        type: s2be
      - id: grid_l3_power
        type: s2be


  data_msg_payload_microinverter:
    seq:
      - size: 5
      - id: unknown_counter_1
        type: u2be
      - size: 8
      - id: unknown_counter_2
        type: u2le
      - size: 2
      - id: inverter_id
        size: 10
      - id: unknown2
        type: u2le
      - id: kwh_today
        type: u4le
      - id: kwh_total
        type: u4le
      - size: 4
      - id: grid_v
        type: u2le
      - size: 4
      - id: grid_i
        type: u2le
      - size: 4
      - id: grid_freq_hz
        type: u2le
      - id: grid_active_power_w
        type: u4le
      - id: inverter_radiator_temp_celsius
        type: s2le
      - size: 20
      - id: pv_1_v
        type: u2le
      - id: pv_1_i
        type: u2le
      - id: pv_2_v
        type: u2le
      - id: pv_2_i
        type: u2le
      - id: pv_3_v
        type: u2le
      - id: pv_3_i
        type: u2le
      - id: pv_4_v
        type: u2le
      - id: pv_4_i
        type: u2le
      - id: protocol_ver
        type: str
        size: 8
        encoding: ASCII
      - id: dc_master_fw_version
        type: str
        size: 8
        encoding: ASCII
      - id: ac_fw_version
        type: str
        size: 8
        encoding: ASCII
      - size: 4
      - id: inverter_rated_power_w
        type: u2be
      - id: mppt_count
        type: u1
      - id: phase_count
        type: u1
      - size: 3
      - id: pv_1_kwh_today
        type: u2le
      - id: pv_2_kwh_today
        type: u2le
      - id: pv_3_kwh_today
        type: u2le
      - id: pv_4_kwh_today
        type: u2le
      - size: 1
      - id: pv_1_kwh_total
        type: u2be
      - size: 2
      - id: pv_2_kwh_total
        type: u2be
      - size: 2
      - id: pv_3_kwh_total
        type: u2be
      - size: 2
      - id: pv_4_kwh_total
        type: u2be
      - id: pv_ids
        size: 64
      - id: grid_freq_hz_overfreq_load_reduction_starting_point
        type: u2be
      - id: grid_overfreq_load_reduction_percent
        type: u2be
      - size: 8
      - id: grid_v_limit_upper
        type: u2be
      - id: grid_v_limit_lower
        type: u2be
      - id: grid_freq_hz_limit_upper
        type: u2be
      - id: grid_freq_hz_limit_lower
        type: u2be
      - id: startup_self_check_time
        type: u2be
      - id: current_time
        size: 6
  
  
  wifi_msg_payload:
    seq:
      - id: schema
        enum: wifi_msg_payload_schema
        type: u1
      - id: maybe_uptime
        type: u2le
      - id: some_count
        type: u2le

      - id: maybe_connection_time_seconds
        type: u2le
      - id: unknown2
        type: u2le
      - id: unknown3
        type: u2le
      - id: unknown5
        type: u2le
      - id: unknown7
        type: u1
      - id: unknonw8
        type: u1
      - id: data
        size-eos: true
        type:
          switch-on: schema
          cases:
            "wifi_msg_payload_schema::foo": wifi_msg_payload_baz #intentional
            "wifi_msg_payload_schema::bar": wifi_msg_payload_bar
            "wifi_msg_payload_schema::baz": wifi_msg_payload_baz
  
  wifi_msg_payload_bar:
    seq:
      - id: inverter_sn
        size: 10
        type: str
        encoding: ASCII
      - id: data
        size-eos: true
  wifi_msg_payload_baz:
    seq:
      - id: ssid
        type: str
        size: 30
        encoding: ASCII
      - id: signal_quality_pct
        type: u1
      - id: some_constant
        contents: [0x01]


enums:
  msg_type:
    0x11: "handshake_response"
    0x12: "data_response"
    0x17: "heartbeat_response"
    0x41: "handshake"
    0x42: "data"
    0x43: "wifi"
    0x45: "command"
    0x47: "heartbeat"
  
  data_msg_payload_schema:
    0x08: "microinverter"
    0x11: "hybridinverter"
    0x13: "relaymodule"
  
  wifi_msg_payload_schema:
    0x01: "foo"
    0x04: "bar"
    0x81: "baz"


================================================
FILE: dummycloud/.automated.eslintrc.json
================================================
{
  "rules": {
    "brace-style": [
      "error",
      "1tbs"
    ],
    "no-trailing-spaces": [
      "error",
      {
        "ignoreComments": true
      }
    ],
    "keyword-spacing": "error",
    "eol-last": [
      "error",
      "always"
    ],
    "no-multi-spaces": [
      "error",
      {
        "ignoreEOLComments": true
      }
    ],
    "semi": [
      "error",
      "always"
    ],
    "quotes": [
      "error",
      "double"
    ],
    "indent": [
      "error",
      4,
      {
        "SwitchCase": 1
      }
    ],
    "no-empty": "error"
  }
}

================================================
FILE: dummycloud/.eslintrc.json
================================================
{
  "env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "node": true,
    "mocha": true
  },
  "plugins": ["jsdoc", "sort-keys-fix", "sort-requires", "regexp"],
  "extends": ["eslint:recommended", "plugin:regexp/recommended"],
  "ignorePatterns": ["dist/*.js"],
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module"
  },
  "settings": {
    "jsdoc": {
      "mode": "closure",
      "tagNamePreference": {
        "returns": "returns",
        "augments": "extends"
      }
    }
  },
  "rules": {
    "no-labels": "error",
    "max-classes-per-file": "error",
    "eqeqeq": "error",
    "curly": "error",
    "default-case-last": "error",
    "block-scoped-var": "error",
    "no-new": "error",
    "no-multi-str": "error",
    "no-new-wrappers": "error",
    "no-sequences": "error",
    "no-self-compare": "error",
    "no-multi-assign": "error",
    "no-whitespace-before-property": "error",
    "no-magic-numbers": ["off", { "ignoreArrayIndexes": true }],
    "no-unused-vars": ["warn", { "args": "none" }],
    "jsdoc/check-alignment": "error",
    "jsdoc/check-param-names": "error",
    "jsdoc/check-tag-names": "error",
    "jsdoc/check-types": "error",
    "jsdoc/implements-on-classes": "error",
    "jsdoc/no-undefined-types": "error",
    "jsdoc/require-param": "error",
    "jsdoc/require-param-name": "error",
    "jsdoc/require-param-type": "error",
    "jsdoc/require-returns-check": "error",
    "jsdoc/require-returns-type": "error",
    "sort-requires/sort-requires": "warn",
    "operator-linebreak": ["error", "after"],
    "no-unneeded-ternary": ["error", { "defaultAssignment": false }],
    "arrow-body-style": ["error", "always"],
    "regexp/no-unused-capturing-group": "off",



    "no-empty": "off",
    "brace-style": "off",
    "no-trailing-spaces": "off",
    "keyword-spacing": "off",
    "eol-last": "off",
    "no-multi-spaces": "off",
    "semi": "off",
    "quotes": "off",
    "indent": "off",
    "no-extra-boolean-cast": "off"


  }
}


================================================
FILE: dummycloud/Dockerfile
================================================
FROM node:lts-alpine

WORKDIR /app
ENV LOGLEVEL="info"
ENV MQTT_BROKER_URL="mqtt://127.0.0.1"

COPY package.json /app
COPY package-lock.json /app

RUN npm ci
COPY . /app

CMD ["npm", "start"]

================================================
FILE: dummycloud/LICENSE
================================================
                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright 2023 Sören Beye

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: dummycloud/Readme.md
================================================
# Deye-dummycloud

This is a small Node.js service that mocks the deye solarman cloud and publishes all the data to an MQTT broker.
It also takes care of Home Assistant autodiscovery leading to things just working.

![dummycloud_demo.png](../img/dummycloud_demo.png)

## Usage

The dummycloud is configured using environment variables to be container-friendly to use.

- `LOGLEVEL` (defaults to `info`)
- `MQTT_BROKER_URL` (no default. Should look like `mqtt://foo.bar`)
- `MQTT_USERNAME` (no default, optional.)
- `MQTT_PASSWORD` (no default, optional.)
- `MQTT_CHECK_CERT` set to `false` for using `mqtts` with self signed certificate (defaults to `true`)

## Inverter Setup

Using the `/config_hide.html` of the inverter webinterface, simply point `Server A Setting` and `Optional Server Setting` to the host this is running on.
I'd still keep the firewall rules preventing the inverter from phoning home in place for good measure.

## Deployment

The dummycloud can be started using `npm run start`. Next to this readme, there's also a dockerfile provided.

A `docker-compose.yml` entry could for example look like this:

```yml
  deye-dummycloud:
    build:
      context: ./deye-microinverter-cloud-free/dummycloud/
      dockerfile: Dockerfile
    container_name: "deye-dummycloud"
    restart: always
    environment:
      - "LOGLEVEL=info"
      - "MQTT_BROKER_URL=mqtt://foobar.example"
      # User those variables if the MQTT broker requires username and password
      # - "MQTT_USERNAME=example-user"
      # - "MQTT_PASSWORD=example-password"
    ports:
      - "10000:10000"
```


================================================
FILE: dummycloud/app.js
================================================
const DummyCloud = require("./src/DummyCloud");
const Logger = require("./src/Logger");
const MqttClient = require("./src/MqttClient");

if (process.env.LOGLEVEL) {
    Logger.setLogLevel(process.env.LOGLEVEL);
}

const dummyCloud = new DummyCloud();
const mqttClient = new MqttClient(dummyCloud);

dummyCloud.initialize();
mqttClient.initialize();


================================================
FILE: dummycloud/package.json
================================================
{
  "name": "deye-dummycloud",
  "version": "1.1.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "node app.js",

    "lint": "eslint -c .automated.eslintrc.json .",
    "lint_fix": "eslint -c .automated.eslintrc.json . --fix"
  },
  "author": "",
  "license": "Apache-2.0",
  "dependencies": {
    "mqtt": "^4.3.7"
  },
  "devDependencies": {
    "eslint": "8.16.0",
    "eslint-plugin-jsdoc": "48.9.3",
    "eslint-plugin-regexp": "1.7.0",
    "eslint-plugin-sort-keys-fix": "1.1.2",
    "eslint-plugin-sort-requires": "git+https://npm@github.com/Hypfer/eslint-plugin-sort-requires.git#2.1.1"
  }
}


================================================
FILE: dummycloud/src/DummyCloud.js
================================================
const EventEmitter = require("events").EventEmitter;
const Logger = require("./Logger");
const net = require("net");
const Protocol = require("./Protocol");

class DummyCloud {
    constructor() {
        this.eventEmitter = new EventEmitter();
        this.server = new net.Server();
    }

    initialize() {
        this.server.listen(
            {
                port: DummyCloud.PORT,
                host: "0.0.0.0"
            }, 
            function() {
                Logger.info(`Starting deye-dummycloud on port ${DummyCloud.PORT}`);
        });

        this.server.on("connection", (socket) => {
            this.handleConnection(socket);
        });
    }

    /**
     * @private
     * @param {net.Socket} socket
     */
    handleConnection(socket) {
        const remoteAddress = socket.remoteAddress; // As this is a getter, it may become unavailable
        Logger.info(`New connection from ${remoteAddress}`);

        socket.on("data", (data) => {
            Logger.trace(new Date().toISOString(), `Data received from client ${remoteAddress}: ${data.toString()}`);
            Logger.trace(new Date().toISOString(), `Data ${remoteAddress}:`, data.toString("hex"));

            try {
                const packet = Protocol.parsePacket(data);
                let response;

                switch (packet.header.type) {
                    case Protocol.MESSAGE_REQUEST_TYPES.HEARTBEAT: {
                        response = Protocol.buildTimeResponse(packet);
                        break;
                    }
                    case Protocol.MESSAGE_REQUEST_TYPES.WIFI: {
                        /*
                            There isn't much of interest in this packet
                            It can contain the SSID or the Logger SN
                            + Some counters increasing every second
                            
                            On connect, it also can contain the signal strength
                            But that's about it
                            
                            The signal strength over time would've been interesting, but it only gets sent on connect
                            With that, it's close to useless
                         */
                        response = Protocol.buildTimeResponse(packet);
                        break;
                    }
                    case Protocol.MESSAGE_REQUEST_TYPES.HANDSHAKE: {
                        const data = Protocol.parseLoggerPacketPayload(packet);

                        Logger.debug(`Handshake packet data from ${remoteAddress}`, data);
                        this.emitHandshake({
                            header: packet.header,
                            payload: data
                        });

                        response = Protocol.buildTimeResponse(packet);
                        break;
                    }
                    case Protocol.MESSAGE_REQUEST_TYPES.DATA: {
                        const data = Protocol.parseDataPacketPayload(packet);

                        if (data) {
                            Logger.debug(`DATA packet data from ${remoteAddress}`, data);
                            this.emitData({
                                header: packet.header,
                                payload: data,
                                meta: {
                                    remoteAddress: remoteAddress
                                }
                            });
                        } else {
                            Logger.debug("Discarded data packet");
                        }

                        response = Protocol.buildTimeResponse(packet);
                        break;
                    }

                    default: {
                        response = Protocol.buildTimeResponse(packet);
                    }
                }

                if (response) {
                    Logger.trace("Response", response.toString("hex"));

                    socket.write(response);
                }
            } catch (e) {
                Logger.error(`Error while parsing packet from ${remoteAddress}`, e);
            }
        });

        socket.on("end", function() {
            Logger.info(`Ending connection with ${remoteAddress}`);
        });

        socket.on("close", function() {
            Logger.info(`Closing connection with ${remoteAddress}`);
        });

        socket.on("error", function(err) {
            Logger.error(`Error on dummycloud socket for ${remoteAddress}`, err);
        });
    }

    emitData(data) {
        this.eventEmitter.emit(DummyCloud.PACKET_EVENTS.Data, data);
    }

    onData(listener) {
        this.eventEmitter.on(DummyCloud.PACKET_EVENTS.Data, listener);
    }

    emitHandshake(data) {
        this.eventEmitter.emit(DummyCloud.PACKET_EVENTS.Handshake, data);
    }

    onHandshake(listener) {
        this.eventEmitter.on(DummyCloud.PACKET_EVENTS.Handshake, listener);
    }
}

DummyCloud.PACKET_EVENTS = {
    Data: "Data",
    Handshake: "Handshake"
};


DummyCloud.PORT = 10000;

module.exports = DummyCloud;


================================================
FILE: dummycloud/src/Logger.js
================================================
const util = require("util");

class Logger {
    constructor() {
        this.logLevel = Logger.LogLevels["info"];
    }

    /**
     * @public
     * @return {string}
     */
    getLogLevel() {
        return Object.keys(Logger.LogLevels).find(key => {
            return Logger.LogLevels[key] === this.logLevel;
        });
    }

    /**
     * @public
     * @param {string} value
     */
    setLogLevel(value) {
        if (Logger.LogLevels[value] === undefined) {
            throw new Error(`Invalid log level '${value}', valid are '${Object.keys(Logger.LogLevels).join("','")}'`);
        } else {
            this.logLevel = Logger.LogLevels[value];
        }
    }


    /**
     * @private
     * @param {string} logLevel
     * @return {string}
     */
    buildLogLinePrefix(logLevel) {
        return `[${new Date().toISOString()}] [${logLevel}]`;
    }

    /**
     * @param {string} level
     * @param {...any} args
     * @private
     */
    log(level, ...args) {
        if (this.logLevel["level"] <= Logger.LogLevels[level]["level"]) {
            const logLinePrefix = this.buildLogLinePrefix(level.toUpperCase());
            const logLine = [logLinePrefix, ...args].map(arg => {
                if (typeof arg === "string") {
                    return arg;
                }

                return util.inspect(
                    arg,
                    {
                        depth: Infinity
                    }
                );
            }).join(" ");

            Logger.LogLevels[level]["callback"](logLine);
        }
    }

    /**
     * @public
     * @see console.trace
     * @param  {...any} args
     */
    trace(...args) {
        this.log("trace", ...args);
    }

    /**
     * @public
     * @see console.debug
     * @param  {...any} args
     */
    debug(...args) {
        this.log("debug", ...args);
    }

    /**
     * @public
     * @see console.info
     * @param  {...any} args
     */
    info(...args) {
        this.log("info", ...args);
    }

    /**
     * @public
     * @see console.warn
     * @param  {...any} args
     */
    warn(...args) {
        this.log("warn", ...args);
    }

    /**
     * @public
     * @see console.error
     * @param  {...any} args
     */
    error( ...args) {
        this.log("error", ...args);
    }
}

Logger.LogLevels = Object.freeze({
    // eslint-disable-next-line no-console
    "trace": {"level": -2, "callback": console.debug},
    // eslint-disable-next-line no-console
    "debug": {"level": -1, "callback": console.debug},
    // eslint-disable-next-line no-console
    "info": {"level": 0, "callback": console.info},
    // eslint-disable-next-line no-console
    "warn": {"level": 1, "callback": console.warn},
    // eslint-disable-next-line no-console
    "error": {"level": 2, "callback": console.error},
});

module.exports = new Logger();


================================================
FILE: dummycloud/src/MqttClient.js
================================================
const Logger = require("./Logger");
const mqtt = require("mqtt");


class MqttClient {
    /**
     *
     * @param {import("./DummyCloud")} dummyCloud
     */
    constructor(dummyCloud) {
        this.dummyCloud = dummyCloud;

        this.autoconfTimestamps = {};

        this.dummyCloud.onHandshake((data) => {
            this.handleHandshake(data);
        });
        this.dummyCloud.onData((data) => {
            this.handleData(data);
        });
    }

    initialize() {
        const options = {
            clientId: `deye_dummycloud_${Math.random().toString(16).slice(2, 9)}`,  // 23 characters allowed
        };

        if (process.env.MQTT_USERNAME) {
            options.username = process.env.MQTT_USERNAME;

            if (process.env.MQTT_PASSWORD) {
                options.password = process.env.MQTT_PASSWORD;
            }
        } else if (process.env.MQTT_PASSWORD) {
            // MQTT_PASSWORD is set but MQTT_USERNAME is not
            Logger.error("MQTT_PASSWORD is set but MQTT_USERNAME is not. MQTT_USERNAME must be set if MQTT_PASSWORD is set.");
            process.exit(1);
        }

        if (process.env.MQTT_CHECK_CERT) {
            options.rejectUnauthorized = (process.env.MQTT_CHECK_CERT !== "false");
        }

        this.client = mqtt.connect(process.env.MQTT_BROKER_URL, options);

        this.client.on("connect", () => {
            Logger.info("Connected to MQTT broker");
        });

        this.client.on("error", (e) => {
            if (e && e.message === "Not supported") {
                Logger.info("Connected to non-standard-compliant MQTT Broker.");
            } else {
                Logger.error("MQTT error:", e.toString());
            }
        });

        this.client.on("reconnect", () => {
            Logger.info("Attempting to reconnect to MQTT broker");
        });
    }

    handleHandshake(data) {
        // Nothing to see here
    }

    handleData(data) {
        this.ensureAutoconf(data.meta, data.header.loggerSerial.toString(), data.payload.inverter_meta.mppt_count);
        const baseTopic = `${MqttClient.TOPIC_PREFIX}/${data.header.loggerSerial.toString()}`;

        for (let i = 1; i <= data.payload.inverter_meta.mppt_count; i++) {
            this.client.publish(`${baseTopic}/pv/${i}/v`, data.payload.pv[`${i}`].v.toString());
            this.client.publish(`${baseTopic}/pv/${i}/i`, data.payload.pv[`${i}`].i.toString());
            this.client.publish(`${baseTopic}/pv/${i}/w`, data.payload.pv[`${i}`].w.toString());
            this.client.publish(
                `${baseTopic}/pv/${i}/kWh_today`,
                data.payload.pv[`${i}`].kWh_today.toString(),
                {retain: true}
            );

            if (data.payload.pv[`${i}`].kWh_total > 0) {
                this.client.publish(
                    `${baseTopic}/pv/${i}/kWh_total`,
                    data.payload.pv[`${i}`].kWh_total.toString(),
                    {retain: true}
                );
            }
        }

        this.client.publish(`${baseTopic}/grid/active_power_w`, data.payload.grid.active_power_w.toString());

        this.client.publish(
            `${baseTopic}/grid/kWh_today`,
            data.payload.grid.kWh_today.toString(),
            {retain: true}
        );
        if (data.payload.grid.kWh_total > 0) {
            this.client.publish(
                `${baseTopic}/grid/kWh_total`,
                data.payload.grid.kWh_total.toString(),
                {retain: true}
            );
        }
        this.client.publish(`${baseTopic}/grid/v`, data.payload.grid.v.toString());
        this.client.publish(`${baseTopic}/grid/hz`, data.payload.grid.hz.toString());

        this.client.publish(`${baseTopic}/inverter/radiator_temperature`, data.payload.inverter.radiator_temp_celsius.toString());


        const totalDcPower = Object.values(data.payload.pv).reduce((sum, pv) => sum + pv.w, 0);
        const acPower = Math.abs(data.payload.grid.active_power_w);
        const efficiency = totalDcPower > 0 && totalDcPower > acPower ? ((acPower / totalDcPower) * 100).toFixed(2) : "null";

        this.client.publish(`${baseTopic}/inverter/efficiency`, efficiency);
    }

    ensureAutoconf(meta, loggerSerial, mpptCount) {
        // (Re-)publish every 4 hours
        if (Date.now() - (this.autoconfTimestamps[loggerSerial] ?? 0) <= 4 * 60 * 60 * 1000) {
            return;
        }
        const baseTopic = `${MqttClient.TOPIC_PREFIX}/${loggerSerial.toString()}`;
        const device = {
            "manufacturer":"Deye",
            "model":"Microinverter",
            "name":`Deye Microinverter ${loggerSerial}`,
            "configuration_url": `http://${meta.remoteAddress}/index_cn.html`,
            "identifiers":[
                `deye_dummycloud_${loggerSerial}`
            ]
        };

        for (let i = 1; i <= mpptCount; i++) {
            this.client.publish(
                `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_pv${i}_v/config`,
                JSON.stringify({
                    "state_topic": `${baseTopic}/pv/${i}/v`,
                    "name":`PV ${i} Voltage`,
                    "unit_of_measurement": "V",
                    "device_class": "voltage",
                    "state_class": "measurement",
                    "object_id": `deye_dummycloud_${loggerSerial}_pv_${i}_v`,
                    "unique_id": `deye_dummycloud_${loggerSerial}_pv_${i}_v`,
                    "expire_after": 360,
                    "enabled_by_default": i < 3,
                    "device": device
                }),
                {retain: true}
            );
            this.client.publish(
                `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_pv${i}_i/config`,
                JSON.stringify({
                    "state_topic": `${baseTopic}/pv/${i}/i`,
                    "name":`PV ${i} Current`,
                    "unit_of_measurement": "A",
                    "device_class": "current",
                    "state_class": "measurement",
                    "object_id": `deye_dummycloud_${loggerSerial}_pv_${i}_i`,
                    "unique_id": `deye_dummycloud_${loggerSerial}_pv_${i}_i`,
                    "expire_after": 360,
                    "enabled_by_default": i < 3,
                    "device": device
                }),
                {retain: true}
            );
            this.client.publish(
                `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_pv${i}_w/config`,
                JSON.stringify({
                    "state_topic": `${baseTopic}/pv/${i}/w`,
                    "name":`PV ${i} Power`,
                    "unit_of_measurement": "W",
                    "device_class": "power",
                    "state_class": "measurement",
                    "object_id": `deye_dummycloud_${loggerSerial}_pv_${i}_w`,
                    "unique_id": `deye_dummycloud_${loggerSerial}_pv_${i}_w`,
                    "expire_after": 360,
                    "enabled_by_default": i < 3,
                    "device": device
                }),
                {retain: true}
            );

            this.client.publish(
                `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_pv${i}_kWh_today/config`,
                JSON.stringify({
                    "state_topic": `${baseTopic}/pv/${i}/kWh_today`,
                    "name":`PV ${i} Energy Today`,
                    "unit_of_measurement": "kWh",
                    "device_class": "energy",
                    "state_class": "total_increasing",
                    "object_id": `deye_dummycloud_${loggerSerial}_pv_${i}_kWh_today`,
                    "unique_id": `deye_dummycloud_${loggerSerial}_pv_${i}_kWh_today`,
                    "enabled_by_default": i < 3,
                    "device": device
                }),
                {retain: true}
            );
            this.client.publish(
                `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_pv${i}_kWh_total/config`,
                JSON.stringify({
                    "state_topic": `${baseTopic}/pv/${i}/kWh_total`,
                    "name":`PV ${i} Energy Total`,
                    "unit_of_measurement": "kWh",
                    "device_class": "energy",
                    "state_class": "total_increasing",
                    "object_id": `deye_dummycloud_${loggerSerial}_pv_${i}_kWh_total`,
                    "unique_id": `deye_dummycloud_${loggerSerial}_pv_${i}_kWh_total`,
                    "enabled_by_default": i < 3,
                    "device": device
                }),
                {retain: true}
            );
        }


        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_grid_active_power_w/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/grid/active_power_w`,
                "name":"Grid Power (Active)",
                "unit_of_measurement": "W",
                "device_class": "power",
                "state_class": "measurement",
                "object_id": `deye_dummycloud_${loggerSerial}_grid_active_power_w`,
                "unique_id": `deye_dummycloud_${loggerSerial}_grid_active_power_w`,
                "expire_after": 360,
                "device": device
            }),
            {retain: true}
        );
        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_grid_kWh_today/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/grid/kWh_today`,
                "name":"Grid Energy Today",
                "unit_of_measurement": "kWh",
                "device_class": "energy",
                "state_class": "total_increasing",
                "object_id": `deye_dummycloud_${loggerSerial}_grid_energy_today`,
                "unique_id": `deye_dummycloud_${loggerSerial}_grid_energy_today`,
                "device": device
            }),
            {retain: true}
        );
        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_grid_kWh_total/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/grid/kWh_total`,
                "name":"Grid Energy Total",
                "unit_of_measurement": "kWh",
                "device_class": "energy",
                "state_class": "total_increasing",
                "object_id": `deye_dummycloud_${loggerSerial}_grid_energy_total`,
                "unique_id": `deye_dummycloud_${loggerSerial}_grid_energy_total`,
                "device": device
            }),
            {retain: true}
        );
        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_grid_v/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/grid/v`,
                "name":"Grid Voltage",
                "unit_of_measurement": "V",
                "device_class": "voltage",
                "state_class": "measurement",
                "object_id": `deye_dummycloud_${loggerSerial}_grid_v`,
                "unique_id": `deye_dummycloud_${loggerSerial}_grid_v`,
                "expire_after": 360,
                "device": device
            }),
            {retain: true}
        );
        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_grid_hz/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/grid/hz`,
                "name":"Grid Frequency",
                "unit_of_measurement": "Hz",
                "device_class": "frequency",
                "state_class": "measurement",
                "object_id": `deye_dummycloud_${loggerSerial}_grid_hz`,
                "unique_id": `deye_dummycloud_${loggerSerial}_grid_hz`,
                "expire_after": 360,
                "device": device
            }),
            {retain: true}
        );

        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_inverter_radiator_temperature/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/inverter/radiator_temperature`,
                "name":"Radiator Temperature",
                "unit_of_measurement": "°C",
                "device_class": "temperature",
                "state_class": "measurement",
                "object_id": `deye_dummycloud_${loggerSerial}_inverter_radiator_temperature`,
                "unique_id": `deye_dummycloud_${loggerSerial}_inverter_radiator_temperature`,
                "expire_after": 360,
                "device": device
            }),
            {retain: true}
        );

        this.client.publish(
            `homeassistant/sensor/deye_dummycloud_${loggerSerial}/${loggerSerial}_inverter_efficiency/config`,
            JSON.stringify({
                "state_topic": `${baseTopic}/inverter/efficiency`,
                "name":"Inverter Efficiency",
                "unit_of_measurement": "%",
                "entity_category": "diagnostic",
                "icon": "mdi:cog-transfer",
                "state_class": "measurement",
                "object_id": `deye_dummycloud_${loggerSerial}_inverter_efficiency`,
                "unique_id": `deye_dummycloud_${loggerSerial}_inverter_efficiency`,
                "expire_after": 360,
                "value_template": "{{ value_json }}",
                "device": device
            }),
            {retain: true}
        );

        this.autoconfTimestamps[loggerSerial] = Date.now();
    }
}

MqttClient.TOPIC_PREFIX = "deye-dummycloud";

module.exports = MqttClient;


================================================
FILE: dummycloud/src/Protocol.js
================================================
const Logger = require("./Logger");
const {getKeyByValue, truncateToNullTerminator} = require("./util");

const HEADER_LEN = 11;
const FOOTER_LEN = 2;

class Protocol {
    static parseHeader(buf) {
        const result = {
            magic: buf[0], //should be 0xa5
            payloadLength: buf.readUInt16LE(1),
            unknown1: buf[3],
            type: buf[4],
            msgIDResponse: buf[5],
            msgIDRequest: buf[6],
            loggerSerial: buf.readUint32LE(7)
        };

        if (result.magic !== 0xa5) {
            throw new Error("Invalid header magic: " + result.magic);
        }

        if (result.payloadLength + HEADER_LEN + FOOTER_LEN !== buf.length) {
            throw new Error("Payload length from header doesn't match packet length. Truncated?");
        }

        return result;
    }

    static parseFooter(buf) {
        const result = {
            checksum: buf[buf.length - 2],
            magic: buf[buf.length - 1] //should always be 0x15
        };

        if (result.magic !== 0x15) {
            throw new Error("Invalid footer magic: " + result.magic);
        }

        return result;
    }

    static checksum(msgBuf) {
        const slice = msgBuf.subarray(1, msgBuf.length - 2); //exclude magic bytes and checksum
        let sum = 0;

        for (let i = 0; i < slice.length; i++) {
            sum = (sum + slice[i]) & 255;
        }

        return sum & 255;
    }


    static parsePacket(buf) {
        const header = Protocol.parseHeader(buf);

        const typeStr = getKeyByValue(Protocol.MESSAGE_REQUEST_TYPES, header.type);
        if (typeStr) {
            Logger.debug(`Received packet of type "${typeStr}"`);
        } else {
            Logger.warn(`Received packet of unknown type "0x${header.type.toString(16)}"`);
        }

        return {
            header: header,
            payload: buf.subarray(HEADER_LEN, buf.length - FOOTER_LEN)
        };
    }

    static parseDataPacketPayload(packet) {
        switch (packet.payload[1]) {
            case Protocol.DATA_PACKET_SCHEMAS.MICROINVERTER:
                return Protocol.parseDataPacketMicroinverterPayload(packet);
            default:
                return null; //TODO: parse relay and string inverter packets
        }


    }

    static parseDataPacketMicroinverterPayload(packet) {
        if (!!(packet.payload[0] & 0b10000000)) {
            // Seems to be one of these weird historic data packets from the SUN-M series. Ignoring for now
            // TODO: understand what they mean and how they should be handled
            return null;
        }

        //TODO: there's a lot more in this packet

        return {
            pv: {
                "1": {
                    v: packet.payload.readUInt16LE(85) / 10,
                    i: packet.payload.readUInt16LE(87) / 10,

                    w: parseFloat(((packet.payload.readUInt16LE(85) / 10) * (packet.payload.readUInt16LE(87) / 10)).toFixed(2)),

                    kWh_today: packet.payload.readUInt16LE(136) / 10,
                    kWh_total: packet.payload.readUInt16BE(145) / 10,
                },
                "2": {
                    v: packet.payload.readUInt16LE(89) / 10,
                    i: packet.payload.readUInt16LE(91) / 10,

                    w: parseFloat(((packet.payload.readUInt16LE(89) / 10) * (packet.payload.readUInt16LE(91) / 10)).toFixed(2)),

                    kWh_today: packet.payload.readUInt16LE(138) / 10,
                    kWh_total: packet.payload.readUInt16BE(149) / 10,
                },
                "3": {
                    v: packet.payload.readUInt16LE(93) / 10,
                    i: packet.payload.readUInt16LE(95) / 10,

                    w: parseFloat(((packet.payload.readUInt16LE(93) / 10) * (packet.payload.readUInt16LE(95) / 10)).toFixed(2)),

                    kWh_today: packet.payload.readUInt16LE(140) / 10,
                    kWh_total: packet.payload.readUInt16BE(153) / 10,
                },
                "4": {
                    v: packet.payload.readUInt16LE(97) / 10,
                    i: packet.payload.readUInt16LE(99) / 10,

                    w: parseFloat(((packet.payload.readUInt16LE(97) / 10) * (packet.payload.readUInt16LE(99) / 10)).toFixed(2)),

                    kWh_today: packet.payload.readUInt16LE(142) / 10,
                    kWh_total: packet.payload.readUInt16BE(157) / 10,
                },
            },
            grid: {
                active_power_w: packet.payload.readUInt32LE(59),

                kWh_today: packet.payload.readUInt32LE(33) / 100,
                kWh_total: packet.payload.readUInt32LE(37) / 10,

                v: packet.payload.readUInt16LE(45) / 10,
                i: packet.payload.readUInt16LE(51) / 10,

                hz: packet.payload.readUInt16LE(57) / 100,

            },
            inverter: {
                radiator_temp_celsius: packet.payload.readInt16LE(63) / 100, //TODO: is this actually a signed int?
            },
            inverter_meta: {
                rated_power_w: packet.payload.readUInt16BE(129) / 10,
                mppt_count: packet.payload.readInt8(131),
                phase_count: packet.payload.readInt8(132),

                startup_self_check_time: packet.payload.readUInt16BE(243),
                current_time: Protocol.parseTime(packet.payload.subarray(245, 251)),


                grid_freq_hz_overfreq_load_reduction_starting_point: packet.payload.readUInt16BE(223) / 100,
                grid_overfreq_load_reduction_percent: packet.payload.readUInt16BE(225),

                grid_v_limit_upper: packet.payload.readUInt16BE(235) / 10,
                grid_v_limit_lower: packet.payload.readUInt16BE(237) / 10,
                grid_freq_hz_limit_upper: packet.payload.readUInt16BE(239) / 100,
                grid_freq_hz_limit_lower: packet.payload.readUInt16BE(241) / 100,

                protocol_ver: packet.payload.subarray(101, 109).toString("ascii"),
                dc_master_fw_ver: packet.payload.subarray(109, 117).toString("ascii"),
                ac_fw_ver: packet.payload.subarray(117, 125).toString("ascii"),
            },

            //for some reason everything after byte ~120 is all BE compared to the above?

        };
    }

    static parseLoggerPacketPayload(packet) {
        //TODO: there's a lot more in this packet
        return {
            fw_ver: truncateToNullTerminator(packet.payload.subarray(19, 60).toString("ascii")),
            ip: truncateToNullTerminator(packet.payload.subarray(65, 82).toString("ascii")),
            ver: truncateToNullTerminator(packet.payload.subarray(89, 130).toString("ascii")), //hw revision maybe?
            ssid: truncateToNullTerminator(packet.payload.subarray(172, 210).toString("ascii")),
        };
    }

    static buildTimeResponse(packet) {
        const response = Buffer.alloc(23);

        // header
        response[0] = 0xa5; //magic
        response.writeUInt16LE(10, 1); //payload len
        response[3] = packet.header.unknown1;
        response[4] = packet.header.type - 0x30; // set type to response for that type
        response[5] = packet.header.msgIDResponse + 1;
        response[6] = packet.header.msgIDRequest;
        response.writeUint32LE(packet.header.loggerSerial, 7);
        // end header

        response[11] = packet.payload[0];
        response[12] = 0x01;

        response.writeUint32LE(
            Math.round(Date.now()/1000),
            13
        );
        response.writeUint32LE(
            0,
            17
        );


        response[response.length - 2] = Protocol.checksum(response);
        response[response.length - 1] = 0x15; //magic

        return response;
    }

    static parseTime(buf) {
        return new Date(
            [
                `${2000 + buf[0]}-${buf[1].toString().padStart(2, "0")}-${buf[2].toString().padStart(2, "0")}T`,
                `${buf[3].toString().padStart(2, "0")}:${buf[4].toString().padStart(2, "0")}:${buf[5].toString().padStart(2, "0")}Z`
            ].join("")
        );
    }
}

Protocol.MESSAGE_REQUEST_TYPES = {
    HANDSHAKE: 0x41,
    DATA: 0x42,
    WIFI: 0x43,
    HEARTBEAT: 0x47,
};

Protocol.MESSAGE_RESPONSE_TYPES = {
    HANDSHAKE: 0x11,
    DATA: 0x12,
    // wifi info reply is 0x13?
    HEARTBEAT: 0x17,
};

Protocol.DATA_PACKET_SCHEMAS = {
    MICROINVERTER: 0x08,
    HYBRIDINVERTER: 0x11,
    RELAYMODULE: 0x13
};

module.exports = Protocol;


================================================
FILE: dummycloud/src/util.js
================================================

function getKeyByValue(obj, value) {
    for (const key in obj) {
        // eslint-disable-next-line no-prototype-builtins
        if (obj.hasOwnProperty(key) && obj[key] === value) {
            return key;
        }
    }
}

function truncateToNullTerminator(str) {
    const nullTerminatorIndex = str.indexOf("\0");
    if (nullTerminatorIndex !== -1) {
        return str.slice(0, nullTerminatorIndex);
    } else {
        return str;
    }
}


module.exports = {
    getKeyByValue: getKeyByValue,
    truncateToNullTerminator: truncateToNullTerminator
};
Download .txt
gitextract_nannntza/

├── .gitignore
├── Readme.md
├── assets/
│   └── deye_sun600.ksy
└── dummycloud/
    ├── .automated.eslintrc.json
    ├── .eslintrc.json
    ├── Dockerfile
    ├── LICENSE
    ├── Readme.md
    ├── app.js
    ├── package.json
    └── src/
        ├── DummyCloud.js
        ├── Logger.js
        ├── MqttClient.js
        ├── Protocol.js
        └── util.js
Download .txt
SYMBOL INDEX (39 symbols across 5 files)

FILE: dummycloud/src/DummyCloud.js
  class DummyCloud (line 6) | class DummyCloud {
    method constructor (line 7) | constructor() {
    method initialize (line 12) | initialize() {
    method handleConnection (line 31) | handleConnection(socket) {
    method emitData (line 123) | emitData(data) {
    method onData (line 127) | onData(listener) {
    method emitHandshake (line 131) | emitHandshake(data) {
    method onHandshake (line 135) | onHandshake(listener) {

FILE: dummycloud/src/Logger.js
  class Logger (line 3) | class Logger {
    method constructor (line 4) | constructor() {
    method getLogLevel (line 12) | getLogLevel() {
    method setLogLevel (line 22) | setLogLevel(value) {
    method buildLogLinePrefix (line 36) | buildLogLinePrefix(logLevel) {
    method log (line 45) | log(level, ...args) {
    method trace (line 70) | trace(...args) {
    method debug (line 79) | debug(...args) {
    method info (line 88) | info(...args) {
    method warn (line 97) | warn(...args) {
    method error (line 106) | error( ...args) {

FILE: dummycloud/src/MqttClient.js
  class MqttClient (line 5) | class MqttClient {
    method constructor (line 10) | constructor(dummyCloud) {
    method initialize (line 23) | initialize() {
    method handleHandshake (line 63) | handleHandshake(data) {
    method handleData (line 67) | handleData(data) {
    method ensureAutoconf (line 117) | ensureAutoconf(meta, loggerSerial, mpptCount) {

FILE: dummycloud/src/Protocol.js
  constant HEADER_LEN (line 4) | const HEADER_LEN = 11;
  constant FOOTER_LEN (line 5) | const FOOTER_LEN = 2;
  class Protocol (line 7) | class Protocol {
    method parseHeader (line 8) | static parseHeader(buf) {
    method parseFooter (line 30) | static parseFooter(buf) {
    method checksum (line 43) | static checksum(msgBuf) {
    method parsePacket (line 55) | static parsePacket(buf) {
    method parseDataPacketPayload (line 71) | static parseDataPacketPayload(packet) {
    method parseDataPacketMicroinverterPayload (line 82) | static parseDataPacketMicroinverterPayload(packet) {
    method parseLoggerPacketPayload (line 172) | static parseLoggerPacketPayload(packet) {
    method buildTimeResponse (line 182) | static buildTimeResponse(packet) {
    method parseTime (line 214) | static parseTime(buf) {

FILE: dummycloud/src/util.js
  function getKeyByValue (line 2) | function getKeyByValue(obj, value) {
  function truncateToNullTerminator (line 11) | function truncateToNullTerminator(str) {
Condensed preview — 15 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (83K chars).
[
  {
    "path": ".gitignore",
    "chars": 26,
    "preview": "/dummycloud/node_modules/\n"
  },
  {
    "path": "Readme.md",
    "chars": 23969,
    "preview": "# Deye Microinverter - Cloud-free\n\n![Deye microinverter in the sun](img/banner.jpg)\n\nSolar power generation work best if"
  },
  {
    "path": "assets/deye_sun600.ksy",
    "chars": 7627,
    "preview": "meta:\n  id: deye_sun600\n\nseq:\n  - id: header\n    type: header\n  - id: payload\n    size: header.payload_length\n    type:\n"
  },
  {
    "path": "dummycloud/.automated.eslintrc.json",
    "chars": 572,
    "preview": "{\n  \"rules\": {\n    \"brace-style\": [\n      \"error\",\n      \"1tbs\"\n    ],\n    \"no-trailing-spaces\": [\n      \"error\",\n      "
  },
  {
    "path": "dummycloud/.eslintrc.json",
    "chars": 2099,
    "preview": "{\n  \"env\": {\n    \"browser\": true,\n    \"commonjs\": true,\n    \"es6\": true,\n    \"node\": true,\n    \"mocha\": true\n  },\n  \"plu"
  },
  {
    "path": "dummycloud/Dockerfile",
    "chars": 191,
    "preview": "FROM node:lts-alpine\n\nWORKDIR /app\nENV LOGLEVEL=\"info\"\nENV MQTT_BROKER_URL=\"mqtt://127.0.0.1\"\n\nCOPY package.json /app\nCO"
  },
  {
    "path": "dummycloud/LICENSE",
    "chars": 11340,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "dummycloud/Readme.md",
    "chars": 1596,
    "preview": "# Deye-dummycloud\n\nThis is a small Node.js service that mocks the deye solarman cloud and publishes all the data to an M"
  },
  {
    "path": "dummycloud/app.js",
    "chars": 349,
    "preview": "const DummyCloud = require(\"./src/DummyCloud\");\nconst Logger = require(\"./src/Logger\");\nconst MqttClient = require(\"./sr"
  },
  {
    "path": "dummycloud/package.json",
    "chars": 625,
    "preview": "{\n  \"name\": \"deye-dummycloud\",\n  \"version\": \"1.1.0\",\n  \"description\": \"\",\n  \"main\": \"app.js\",\n  \"scripts\": {\n    \"start\""
  },
  {
    "path": "dummycloud/src/DummyCloud.js",
    "chars": 5112,
    "preview": "const EventEmitter = require(\"events\").EventEmitter;\nconst Logger = require(\"./Logger\");\nconst net = require(\"net\");\ncon"
  },
  {
    "path": "dummycloud/src/Logger.js",
    "chars": 2874,
    "preview": "const util = require(\"util\");\n\nclass Logger {\n    constructor() {\n        this.logLevel = Logger.LogLevels[\"info\"];\n    "
  },
  {
    "path": "dummycloud/src/MqttClient.js",
    "chars": 13796,
    "preview": "const Logger = require(\"./Logger\");\nconst mqtt = require(\"mqtt\");\n\n\nclass MqttClient {\n    /**\n     *\n     * @param {imp"
  },
  {
    "path": "dummycloud/src/Protocol.js",
    "chars": 8469,
    "preview": "const Logger = require(\"./Logger\");\nconst {getKeyByValue, truncateToNullTerminator} = require(\"./util\");\n\nconst HEADER_L"
  },
  {
    "path": "dummycloud/src/util.js",
    "chars": 563,
    "preview": "\nfunction getKeyByValue(obj, value) {\n    for (const key in obj) {\n        // eslint-disable-next-line no-prototype-buil"
  }
]

About this extraction

This page contains the full source code of the Hypfer/deye-microinverter-cloud-free GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 15 files (77.4 KB), approximately 17.9k tokens, and a symbol index with 39 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!