phev-remote / phev-ttgo

13 stars 2 forks source link

It is working, but.... #4

Open MBj1703 opened 3 years ago

MBj1703 commented 3 years ago

Got my board today and just tried it. It is working in general.

I got the MQTT Topics into my Smarthome: setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_1 88 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_2 250 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_3 207 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_4 233 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_5 173 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_6 173 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_7 165 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_8 21 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_data_9 1 setstate MQTT2_phev_ttgo 2021-02-17 17:50:02 responses_1_startMessage_length 9 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_time 2021-02-17T16:50:02Z setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_1 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_10 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_11 16 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_12 1 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_13 0 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_14 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_15 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_16 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_17 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_18 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_19 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_2 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_20 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_21 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_22 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_23 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_24 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_25 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_26 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_27 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_28 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_29 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_3 54 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_30 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_31 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:03 responses_1_updatedRegister_data_32 255 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_4 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_5 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_6 51 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_7 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_8 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_data_9 48 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_length 13 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_register 192 setstate MQTT2_phev_ttgo 2021-02-17 17:50:05 responses_1_updatedRegister_xor 206 setstate MQTT2_phev_ttgo 2021-02-17 17:47:34 status_dateSync 2021-02-17T17:47:17Z setstate MQTT2_phev_ttgo 2021-02-17 17:47:35 version v0.2-15-g62f5716

Now I would like to "translate" this information in readable format. Therefore I would to like to know, what the different topics mean.

Something like: updatedRegister_data_1 48 = Batterie at 48%

Also I would like to know, how to send. From the example I can see this JSON: { "requests" : [ { "updateRegister" : { "register" : 2, "value" : [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255] } }, {
"operation" : { "airCon" : "on" } } ] }

turns on cooling for 10 minutes. So what are the other commands?

Also here a "translation table" would be helpful.

Thanks a lot!

papawattu commented 3 years ago

I don't actually have the car anymore so I can't really test any of this, however to explain...

The reason it kinda works only some of the time it due to the way the code handles the encryption of the payloads, I never figured out a way to get the keys 100% of the time, but the car leaks the current key which is then used to send commends. If you get lucky it will work, but there's also a retry mechanism to get around the fact some of the commands fail.

the register 2 is to control the timer and the heat mode, if I recall the 7th byte is the mode, first 4 bits are the time and second 4 bits are the mode, you can see the definitions here

https://github.com/phev-remote/phevcore/blob/57d89c2d9dd175eba613d74ce856aa5f766dbb50/include/phev.h#L87

https://github.com/phev-remote/phevcore/blob/57d89c2d9dd175eba613d74ce856aa5f766dbb50/src/phev.c#L340

MBj1703 commented 3 years ago

Ok, thank you. It is a beginning :-)

If I look on your code I found this

`switch(time) { case T10MIN: val |= 0; break; case T20MIN: val |= 16; break; case T30MIN: val |= 32; break; }

uint8_t data[] = {0, 0, 255, 255, 255, 255, val, 255, 255, 255, 255, 255, 255, 255, 255};`

So 10 Minutes would add 0 on number 7 = {0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255}

But this doesn't fit with the example saying 10 Minutes: [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255]

MBj1703 commented 3 years ago

I think the timing stuff is clear.

{ "operation":{"airCon":"on"} turns on AC. How can I send heat? I can find this in the code.

papawattu commented 3 years ago

This command sets the mode, then use the aircon on to switch it on.

{
"updateRegister" : {
"register" : 2,
"value" : [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255]
}
MBj1703 commented 3 years ago

Now I total confused.

"value" : [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255] What does it set exactly? On the main page is written: The command above sets the aircon to ten minute cool. With the exact same value??

Sorry if I'm stressing with all my question. Just learning... :-)

MBj1703 commented 3 years ago

I just started the board in the car and receiving MQTT topics.

When I send

{ "requests" : [ { "updateRegister" : { "register" : 2, "value" : [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255] } }, { "operation" : { "airCon" : "on" } } ] }

nothing happens.

Has anyone got this working?

papawattu commented 3 years ago

"value" : [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255]

The only value that matters is in bold.

so its set to 1 above which means 10 mins heat

1= HEAT and then logic OR with the time 0 which is 10 mins

MBj1703 commented 3 years ago

okay, thanks, understood. But unfortunately, not working.

In the meantime, I got additional readings (which is cool): `

status_battery_soc 94 2021-02-17 21:48:09
status_dateSync 2021-02-17T20:51:56Z 2021-02-17 21:52:21
status_hvac_mode 2 2021-02-17 21:48:09
status_hvac_operating false 2021-02-17 21:48:09
status_hvac_time 2 2021-02-17 21:48:09

`

But what is HVAC Mode and Time?

papawattu commented 3 years ago

30 mins cool

NONE = 0
HEAT = 1
COOL = 2
WINDSCREEN =3

10MIN = 0 20MIN = 1 30MIN =2

MBj1703 commented 3 years ago

Yes it is cooling, that's why it goes to "false".

I'm still struggling sending HEAT.

runestone74 commented 3 years ago

I change the mode from the official app and then change from heat to cool twice a year :) I just send the start HVAC command

ons 17 feb. 2021 kl. 22:03 skrev MBj1703 notifications@github.com:

Yes it is cooling, that's why it goes to "false".

I'm still struggling sending HEAT.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/phev-remote/phev-ttgo/issues/4#issuecomment-780851398, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGFMEU65HFFIKRUFIU4RAYDS7QVJRANCNFSM4XYWXTOA .

MBj1703 commented 3 years ago

I change the mode from the official app and then change from heat to cool twice a year :) I just send the start HVAC command ons 17 feb. 2021 kl. 22:03 skrev MBj1703 notifications@github.com: Yes it is cooling, that's why it goes to "false". I'm still struggling sending HEAT. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#4 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGFMEU65HFFIKRUFIU4RAYDS7QVJRANCNFSM4XYWXTOA .

But what is this command?

The JSON what papawattu said is not working:

`"value" : [0,0,255,255,255,255,1,255,255,255,255,255,255,255,255]

The only value that matters is in bold.

so its set to 1 above which means 10 mins heat

1= HEAT and then logic OR with the time 0 which is 10 mins`

MBj1703 commented 3 years ago

I changed my MQTT server and now I can see something comming in.

When I send to the ESP, I can see the following in the monitor:

I (27053) PHEV_SERVICE: Phev message command F6 reg 02 type 00 length 0F I (27053) PHEV_SERVICE: Sending air con on command I (27053) PHEV_SERVICE: Phev message command F6 reg 04 type 00 length 01

So looks like it receive something, but nothing happens?

MBj1703 commented 3 years ago

Today, after testing around, heating started once. Since then, never again :-(

The connection in general is really fragile. The ESP is restarting often. For me it looks like you need to hit the exact point in time to make the command working.

Also hvac_mode and time are not changing. Both are always 2, like mode are false, even if the heating is starting by schedule.

Here are more logs when sending:

I (44983) MQTT: MQTT_EVENT_DATA I (44983) PHEV_SERVICE: Phev message command F6 reg 02 type 00 length 0F I (44993) PHEV_SERVICE: Sending air con on command I (44993) PHEV_SERVICE: Phev message command F6 reg 04 type 00 length 01 E (51593) PHEV_CORE: Unknown encoded command 79 or 78 E (52523) PHEV_CORE: Unknown encoded command 26 or 27 E (52523) PHEV_PIPE: Could not extract message

MBj1703 commented 3 years ago

Today I played again and got the heating working...just 1 time.... The module is dropping a lot of errors and rebooting every 3 minutes.