dmslabsbr / hoymiles

Hoymiles ADD-ON for Home Assistant
119 stars 31 forks source link

Read data from Layout and Devices tab. #22

Open giacomitti opened 3 years ago

giacomitti commented 3 years ago

Will be very nice if the data on layout (panels) and devices (microinverters) can be readed also.

dmslabsbr commented 2 years ago

Hi, thank you for your suggestion!

Would you explain better?

giacomitti commented 2 years ago

In layout tab, you have the last status o panels, like this:

image

and the historic data also.

Cosik commented 2 years ago

This will required protobuf decoding in python, I was not able to decode it using python. I'm attaching data and proto json demofile2.txt

MrMusk commented 10 months ago

So, I tried to decode demofile2.txt with protobuf-decoder 0.3.0, which can be found at https://pypi.org/project/protobuf-decoder/. However, I'm unable to extract any meaningful structure from the output. Here you can see the output that i got from my code below: output2.txt

decoder.py


# Definition of a recursive function for printing the data
def format_data(parsed_result, indent=0):
    result_str = ""
    result_str += "  " * indent
    result_str += "Field {0}: {1}\n".format(parsed_result.field, parsed_result.data)

    if parsed_result.wire_type == 'length_delimited' and hasattr(parsed_result.data, 'results'):
        for sub_result in parsed_result.data.results:
            result_str += format_data(sub_result, indent + 1)

    return result_str

# Open the binary file
with open('demofile2.txt', 'rb') as file:
    binary_data = file.read()

# Convert the binary data to a hexadecimal string
hex_data = ' '.join(f'{byte:02X}' for byte in binary_data)

# Use the Parser to parse the data
parsed_data = Parser().parse(hex_data)

# Open the output file
with open('output2.txt', 'w') as output_file:
    for result in parsed_data:
        output_file.write(format_data(result))```
Cosik commented 10 months ago

@MrMusk good job. I will need much more time to analyze it. Also I will need to find some some real data and compare it and figure out how to interpret it.

fcarlier commented 1 month ago

Update 25 February 2024 : protobuf-decoder 0.4.0

New to integrate device value in HA ? (I'm used the stable version !)