tadasdanielius / daikin_altherma

Daikin Altherma custom component for home assistant
MIT License
76 stars 6 forks source link

How it works... #73

Closed mkopri closed 1 year ago

mkopri commented 1 year ago

Hi!

This is not really an issue, but I'm wondering, how is Home Assistant connecting to Altherma 3? What protocol does it use, what ports and so on?

I'm not using Home Assistant, but I'm trying to connect using my own program in C#. I didn't find anything regarding local connection using LAN adapter (BRP069A61). I was thinking it is not even possible to get direct connection.

Thanks for your help!

tadasdanielius commented 1 year ago

Sorry for late response but summer is a "busy" time :) If you are still struggling to understand how it works I can try to answer. So, in order to connect to device you have to use websockets address would look like this ws://IP/mca

Now first thing you might want to do is to "discover" the profile of the devices (Space Heating, Water Tank, etc.) Send json message to [0]/MNAE/0/UnitProfile/la

{"m2m:rqp": {"fr": "my_client_name", "rqi": "some_random_value", "op": 2, "to": "[0]/MNAE/0/UnitProfile/la"}}

That would request info about unit 0. Which normally is just an adapter. In order to get more interesting stuff you need to change 0 to 1 or 2. (leave [0] as it is only change after MNAE) [0]/MNAE/1/UnitProfile/la and request message

{"m2m:rqp": {"fr": "my_client_name", "rqi": "some_random_value", "op": 2, "to": "[0]/MNAE/1/UnitProfile/la"}}

That should return the profile of the Space Heating unit or Domestic Hot Water unit. You should expect the similar output

{
    "m2m:rsp": {
        "rsc": 2000,
        "rqi": "48855",
        "to": "pyaltherma",
        "fr": "[0]/MNAE/1/UnitProfile/la",
        "pc": {
            "m2m:cin": {
                "rn": "00000002",
                "ri": "0006_00000002",
                "pi": "0006",
                "ty": 4,
                "ct": "20230421T230242Z",
                "lt": "20230421T230242Z",
                "st": 2,
                "con": "{\"SyncStatus\":\"reboot\",\"Sensor\":[\"IndoorTemperature\",\"OutdoorTemperature\",\"LeavingWaterTemperatureCurrent\"],\"UnitStatus\":[\"ErrorState\",\"InstallerState\",\"WarningState\",\"EmergencyState\",\"TargetTemperatureOverruledState\"],\"Operation\":{\"Power\":[\"on\",\"standby\"],\"OperationMode\":[\"heating\",\"cooling\",\"auto\"],\"LeavingWaterTemperatureOffsetHeating\":{\"maxValue\":10,\"minValue\":-10,\"stepValue\":1,\"settable\":true},\"LeavingWaterTemperatureOffsetCooling\":{\"maxValue\":10,\"minValue\":-10,\"stepValue\":1,\"settable\":true},\"LeavingWaterTemperatureOffsetAuto\":{\"maxValue\":10,\"minValue\":-10,\"stepValue\":1,\"settable\":true}},\"Schedule\":{},\"Consumption\":{\"Electrical\":{\"unit\":\"kWh\",\"Heating\":{\"Daily\":{\"contentCount\":24,\"resolution\":2},\"Weekly\":{\"contentCount\":14,\"resolution\":1},\"Monthly\":{\"contentCount\":24,\"resolution\":1}},\"Cooling\":{\"Daily\":{\"contentCount\":24,\"resolution\":2},\"Weekly\":{\"contentCount\":14,\"resolution\":1},\"Monthly\":{\"contentCount\":24,\"resolution\":1}}}}}"
            }
        }
    }
}

The interesting part is "m2m:rsp" -> "m2m:cin" -> "con"

This gives you info what the unit can do. The relevant part is in this object is Sensors: [\"IndoorTemperature\",\"OutdoorTemperature\",\"LeavingWaterTemperatureCurrent\"] This gives you a list of all sensors the device has exposed. Now you will find definition of the sensors for example LeavingWaterTemperature: {\"maxValue\":10,\"minValue\":-10,\"stepValue\":1,\"settable\":true}. If settable is true then you can set it or if it is not then you can just read it.

Operations for example: Power: [\"on\",\"standby\"], Opeartion Mode: [\"heating\",\"cooling\",\"auto\"] Operation format is Operation and a list of possible options.

So this is regarding profile. Next, you want to query/set Sensors/Operations. You can do this by querying endpoints

/[0]/MNAE/UNIT_ID/Operation/OPERATION_YOU_WANT_TO_WORK/la

OPERATION_YOU_WANT_TO_WORK can be anything you find in the operation part for example Power, OperationMode or TargetTemperature. Note: UNIT_ID should be 0, 1, 2...

For example

/[0]/MNAE/1/Operation/Power/la
/[0]/MNAE/1/Operation/TargetTemperature/la

Here is the request json to get info if the unit is powered on

{"m2m:rqp": {"fr": "pyaltherma", "rqi": "35309", "op": 2, "to": "/[0]/MNAE/1/Operation/Power/la"}}

For other operations change power in endpoint and in the request json

Same goes with sensors (which you find in the profile under Sensors definition)

/[0]/MNAE/UNIT_ID/Sensor/YOUR_SENSOR/la

Example:

/[0]/MNAE/1/Sensor/IndoorTemperature/la
/[0]/MNAE/1/Sensor/OutdoorTemperature/la

(remember to change UNIT_ID)

Now setting the values for example if you want to turn on the boiler you need to send to "operation" endpoint the following json /[0]/MNAE/2/Operation/Power (pay attention we don't have /la at the end)

{"m2m:rqp": {"fr": "pyaltherma", "rqi": "ae77f", "op": 1, "to": "/[0]/MNAE/2/Operation/Power", "ty": 4, "pc": {"m2m:cin": {"con": "on", "cnf": "text/plain:0"}}}}

Pay attention to the "con" part {"con": "on", "cnf": "text/plain:0"} this is what you say todo con values can be everything what you find in the profile description under the Operation Power (e.g. "Power\":[\"on\",\"standby\"])

Similarly, you do for sensors just change endpoints and put "con" what you want to put.

Other endpoints you might want to explore are Status:

/[0]/MNAE/1/UnitStatus/EmergencyState/la
/[0]/MNAE/1/UnitStatus/ErrorState/la
/[0]/MNAE/1/UnitStatus/InstallerState/la

Identification

/[0]/MNAE/1/UnitIdentifier/Icon/la
/[0]/MNAE/1/UnitIdentifier/Name/la

Schedules

/[0]/MNAE/1/Schedule/Next/la

Consumption

/[0]/MNAE/1/Consumption/la

Holidays

/[0]/MNAE/1/Holiday/EndDate/la
/[0]/MNAE/1/Holiday/HolidayState/la
/[0]/MNAE/1/Holiday/StartDate/la

Something todo with childlocks but I haven't used them at all

/[0]/MNAE/1/ChildLock/LockedState/la
/[0]/MNAE/1/ChildLock/PinCode/la

Always pay attention to unit_id.

Sorry that was very non-formatted response. Just throwing some notes. Feel free to ask if you stuck at some point.

mkopri commented 1 year ago

Thank you for sharing that with us! This will help me and others so much!

I found some information just after posting an issue here, but not as detailed as yours. I found an example to read temperatures and setpoints, but I still didn't know how to write them and where to get limits of setpoints, what are possible values of "bool" variables and so on.

You don't need to apologize, explanation is great!

Thanks again!