Updates:

Click here to visit our store! https://www.auberins.com

Controlling the SYL-2381 via Home Assistant

Started by gmartin, February 26, 2023, 03:40:43 PM

Previous topic - Next topic

gmartin

I'm trying to integrate the 2381 with home assistant for a project I'm working on.  I have it connected via rs-485 and can read the SV, PV, AH1, AL1 and AL1_STA without issue. What I am unable to do is successfully write a new SV (or AH,AL).  Regardless of what I write, SV always changes to 0 if it changes at all.

I'm using the HA modbus write-register service. It takes four parameters: Hub name (modbus_hub), unit/slave (2), address (00) and value.  The first three are known correct as I use them to read the values.

It's what to set the `value` to when I write that is the issue. Per the SYL-2381 modbus doc, I need to use function 10H to write to a register, and per the HA docs, I need to provide an array in order to force HA to use function 10H (single value write use function 0x06).

In trying to update the SV to 75, I've tried specifying [00,75] and the result is the SV changing to 0. Using [75,00] or [75] has no effect. Attempting to set AH1 or AL1 similarly give the same result.
(Note: service calls are done using YAML and [..] are the YAML array descriptor.)

Appreciate any help you can offer.

(And FWIW, I was able to make this all work with a Solo controller months ago so I'm somewhat confident that the HA modbus integration works.)
TheHA Docs for modbus

Kkane

I haven't tested this controller with HA modbus before, so I can only proivded limited help.

The set temperature used in this controller is in float point format, not integal. You may need to double confirm if your drive sent the proper value or not. You may need to use some serial port tools on computer to analysis the data frame sent through your HA drive.

The value for decimal number 75 in 32 bit float point is 0x42960000. In other word, you need to send 42960000 in your data frame.

The correct data frame to send command to change the set temperature to 75 if the following:

05 10 00 00 00 02 04 42 96 00 00 12 CB

For the data frame explanation, you can check the example #1 for fuction code 16 on page 4 of its communication guide.

gmartin

I appreciate the quick response.

I can pass a floating point value.  I tried 75.0 with the same results. I'll dig in more with this lead.
Thanks

gmartin

You were spot on!  I changed the write value to [0x4296,0x0000] and was successful in modifying the value.

Thanks again!

Kkane

You're welcome. It seems HA modbus doesn't auto convert integral numbers into float point numbers.

gmartin

Correct, but there is a note in the docs on how to submit FP numbers

gmartin

QuoteThe value for decimal number 75 in 32 bit float point is 0x42960000. In other word, you need to send 42960000 in your data frame.


Can you help with one more thing?  How do I convert 75.0 to 0x42960000?  I should now this, but I am unable to make it work.  0x4296 = 17,046 decimal.  I'm not seeing it

Kkane

#7
There are some online tools to convert the number, like the following one:

https://www.h-schmidt.net/FloatConverter/IEEE754.html

Put your number (like 75) on the "Your entered" line, then hit Enter key on your keyboard. You will see the proper value on the "Hexadecimal Representation" line.

Float number is a complicated way to calculate/store numbers. It is typically under hex format, but it is not a regular hex number.

gmartin

Thanks. I need to do this programmatically.  I'll work it out.