nVuln / homebridge-lg-thinq

A Homebridge plugin for controlling/monitoring LG ThinQ device via their ThinQ platform.
https://github.com/nVuln/homebridge-lg-thinq
Apache License 2.0
194 stars 49 forks source link

ThinQ Oven Support #87

Open nVuln opened 3 years ago

nVuln commented 3 years ago

I'm currently working on Oven implementation, I need collect device data first I already published test version for Oven v1.3.0-oven.1, this version is still not implemented anything, just register Oven as supported device and collecting data

How to install testing version

Select Install Previous Version in Homebridge UI X, choose version started with v1.6.0-test.x

Screen Shot 2021-08-08 at 6 44 40 PM

How to collect device data ?

turn on homebridge debug mode first, then install and setting plugin oven version (v1.6.0-test.x) make sure in your homebridge log showing something like this

[9/23/2021, 12:59:27 PM] [LGThinQ] [Oven] Setting up device!
[9/23/2021, 12:59:29 PM] [LGThinQ] Adding new accessory: 47e159a5-*****: Oven (OVEN LSGL6337F.*****)
[9/23/2021, 12:59:29 PM] [LGThinQ] Start MQTT listener for thinq2 device
[9/23/2021, 12:59:32 PM] [LGThinQ] Successfully connected to the MQTT server.

your Oven is ready now, then make some cook, preheat, adjust temperature ... anything you can do in your oven every action you did, you may got debug log [9/23/2021, 1:11:41 PM] [LGThinQ] mqtt message received:, that is what I need, please upload all debug log

Wanna help ?

I already pushed Oven source code to dev/oven branch, feel free to make PR if you wanna help

Discussed in https://github.com/nVuln/homebridge-lg-thinq/discussions/28

Originally posted by **rrhoade2** July 23, 2021 Are there any plans to add support for the recent LG ThinQ Ovens at some point in the future? I'm wondering specifically about cooktop and oven statuses and oven pre-heat notifications. Thanks!
rdnewt commented 3 years ago

I removed any lines that were relating to a different homebridge package, so that's what all the lines that are just an ellipse is. I didn't realize the log only covers about a day with how much I've got running on it, so I think this only has oven messages. I will try to remember to grab the log again the next time I use the stove top and timer as well. homebridge_thinq.log.txt

everyplace commented 3 years ago

I'll install this plugin this weekend and pull logs from my oven. Thanks for providing instructions on how to do so. My model is the LSD4913ST, so hopefully that'll help.

pjteeter commented 1 year ago

Oven model is WLC389PC. Homebridge debug logging attached. lg_thinq_oven_debug_logging.log.zip

beslergr commented 1 year ago

Oven model is LSGS6338F. Debug logging attached. homebridge.log.txt

carlosgamezvillegas commented 1 year ago

Hello nVuln,

I am currently working on an Oven implementation using your plugin as base, but so far I am only able to get the current status of the oven (I show different options using a TV accessory and the inputs of the TV as different Status messages), however, cannot figure out how to send commands to the oven to start cooking or set timers.

Could you help me out figuring out how to send commands to the oven? When I am done I will be happy to share the code. In addition that I will be also modifying it to support a Microwave as well.

Here is an example of what I have for the oven and what I did for a dishwasher I have. homebridge.log.txt DiswahwerAndOvenJSCode.zip

Kind regards,

nVuln commented 1 year ago

@carlosgamezvillegas you can use a network traffic capture tool to try capture command sent from lg thinq app you can use proxyman.io on mac or fiddler on windows

again, thank you very much for your work, it's hard to working without real device for testing

p/s: found ios version https://apps.apple.com/us/app/proxyman/id1551292695 , no pc needed to debug

carlosgamezvillegas commented 1 year ago

Hello nVuln,

I finished the code to add an LG range with a single oven and an Over the Range Microwave (with Air Fryer). It needs testing but here is the code in case you would like to implement the changes to your code. I also update the Dishwasher to correct some of the bugs I had.

I will report back when/if I find more bugs or make improvements to the code

LG_OVen_CG.zip

let me know if you have any questions

Kind regards,

nVuln commented 1 year ago

Hello nVuln,

I finished the code to add an LG range with a single oven and an Over the Range Microwave (with Air Fryer). It needs testing but here is the code in case you would like to implement the changes to your code. I also update the Dishwasher to correct some of the bugs I had.

I will report back when/if I find more bugs or make improvements to the code

LG_OVen_CG.zip

let me know if you have any questions

Kind regards,

thanks for your work could you share typescript code inside "src" folder? or you can make a PR to this repo, I'll release new version with your new code, let everyone try it because I don't have oven and dishwasher here šŸ«”

carlosgamezvillegas commented 1 year ago

Hello nVuln,

Unfortunately I don't know how to use Typescript or convert the javascript code I wrote to Typescript.

For what is worth here are the files I changed to make the Oven, Microwave and Dishwasher work: Modified Files.zip And here is the whole thing in case I missed something

latest version:

homebridge-lgthinq.zip

kind regards,

nVuln commented 1 year ago

Hello nVuln,

Unfortunately I don't know how to use Typescript or convert the javascript code I wrote to Typescript.

For what is worth here are the files I changed to make the Oven, Microwave and Dishwasher work: Modified Files.zip And here is the whole thing in case I missed something

latest version:

homebridge-lgthinq.zip

kind regards,

thank you so much for your hard work ā¤ļø I'll convert your modified js to typescript, it need a bit time, I'll update here when I'm done again thank you so much šŸ„°

carlosgamezvillegas commented 1 year ago

Hello nVuln,

That is awesome. Just hold off on the conversion if you can. I have discovered and solved new bugs so the version I sent to you last is outdated already. I will send you the latest version on Monday.

Kind regards,

nVuln commented 1 year ago

Hello nVuln,

That is awesome. Just hold off on the conversion if you can. I have discovered and solved new bugs so the version I sent to you last is outdated already. I will send you the latest version on Monday.

Kind regards,

I just created new branch migrate-carlosgamezvillegas to update progress for now I just finished Oven: https://github.com/nVuln/homebridge-lg-thinq/blob/migrate-carlosgamezvillegas/src/devices/Oven.ts also I merged some duplicate code, fixed some typo and syntax too, typescript is similar js

you can checkout new branch, then run npm install & npm run build, compiled code will be in dist folder

I still working on DIshwasher and Microwave, will be update soon

nVuln commented 1 year ago

updated Dishwasher: https://github.com/nVuln/homebridge-lg-thinq/blob/migrate-carlosgamezvillegas/src/devices/Dishwasher.ts I'm working on Microwave too, found this duplicate key on sendOvenCommand function

"cmdOptionSetTargetTimeMinute": Math.floor(this.ovenCommandList.ovenSetDuration % 3600 / 60),
"cmdOptionSetTargetTimeMinute": Math.floor(this.ovenCommandList.ovenSetDuration % 60),

so I'll wait your latest version

carlosgamezvillegas commented 1 year ago

Hello nVuln,

Thank you for catching bugs and making corrections, I am not the best at programming so you will notice a lot of redundanciesĀ and/or unnecessaryĀ things in the code. I have fixed some of the bugs but the code is definitelyĀ not optimizedĀ but at least is working. The major thing I did in this version is to add Ā  addOptionalCharacteristic(this.platform.Characteristic.ConfiguredName) to all the accessoriesĀ so Homekit labels the accessories correctlyĀ instead of naming all of them with the same name.

Let meĀ know if you have any questions,

Kind regards, homebiridge-ThinQ.zip

carlosgamezvillegas commented 1 year ago

Hello again,

Please ignore the last files I sent, use this ones instead.

Homebridge-ThinQV2.zip

Thank you,

nVuln commented 1 year ago

@carlosgamezvillegas yup, we make it working first, then we optimize it later, btw I'm not javascript or typescript programmer too šŸ˜†

nVuln commented 1 year ago

@carlosgamezvillegas I published tag 1.6.0-test.1 implemented your new code, can you test it? I have question, Microwave use same snapshot.ovenState key like Oven ?

carlosgamezvillegas commented 1 year ago

@nVuln, yes, the microwave sues the same ovenState, I think it is because the Microwave that I have is also a convection oven.

By the way, I installed the plugin and I think I had a bug in the Dishwasher.js please find the lines below and change this.startTime for this.courseDuration

Bug: this.courseDuration = this.createInputSourceService('Cycle Duration', 'CataNico-Always20', 4, this.courseTimeString, this.showTime); this.startTime.getCharacteristic(this.platform.Characteristic.ConfiguredName)

Correction: this.courseDuration = this.createInputSourceService('Cycle Duration', 'CataNico-Always20', 4, this.courseTimeString, this.showTime); this.courseDuration.getCharacteristic(this.platform.Characteristic.ConfiguredName).

@beslergr, @rdnewt please try the plugin and let us know if you see something wrong

Kind regards,

beslergr commented 1 year ago

@carlosgamezvillegas seems to work in terms of basic functionality. For the microwave, I can turn it on, but doesn't seem like any of the switches work (that or I'm just clueless on how to do it).

For the oven, it works, but only Bake mode.

carlosgamezvillegas commented 1 year ago

@beslergr The microwave that I have has also a convection oven so if the Microwave only has the microwave function most of the buttons are going to be useless to you.

For the oven, if it is just running Bake mode only it might be because it is the default setting, the way it it works is very similar to the ThinQ app.

  1. Select Bake mode
  2. Select Temperature
  3. Select Bake time (for security if Bake time is not selected it is going use the default duration)
  4. Select probe temperature (optional)
  5. Keep warm (optional)
  6. Turn on the Send command switch to send to command to the Range

Steps 1-5 can be done in any order and must be completed within 2 minutes, after that all the accessories are going to update to reflect the current state of the Range

The timer works independently, after selecting the timer duration just "turn on" the Valve so the command can be sent.

I hope this helps and if you have any other feedback please let me know.

beslergr commented 1 year ago

Iā€™ve got an LG Studio microwave with way too many buttons to know what they all do, but I know thereā€™s a convection option, Air Fry option, and others. What is the basic work through to, say, if I want to set the microwave for 1 minute, power level 60? The oven I was able to figure out, but I canā€™t get the microwave to really do much, outside of running the fan and turning on the lights.

On Jul 5, 2023, at 6:54 PM, carlosgamezvillegas @.***> wrote:

@beslergr https://github.com/beslergr The microwave that I have has also a convection oven so if the Microwave only has the microwave function most of the buttons are going to be useless to you.

For the oven, if it is just running Bake mode only it might be because it is the default setting, the way it it works is very similar to the ThinQ app.

Select Bake mode Select Temperature Select Bake time (for security if Bake time is not selected it is going use the default duration) Select probe temperature (optional) Keep warm (optional) Turn on the Send command switch to send to command to the Range Steps 1-5 can be done in any order and must be completed within 2 minutes, after that all the accessories are going to update to reflect the current state of the Range

The timer works independently, after selecting the timer duration just "turn on" the Valve so the command can be sent.

I hope this helps and if you have any other feedback please let me know.

ā€” Reply to this email directly, view it on GitHub https://github.com/nVuln/homebridge-lg-thinq/issues/87#issuecomment-1622641770, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXYX2HAOZRXJC4IUAVHGWDTXOXWARANCNFSM5ES5QRKQ. You are receiving this because you were mentioned.

carlosgamezvillegas commented 1 year ago

I think it is a security measure fromG, I cannot start the microwave from the ThinQ app either, I always have to physically touch the start bottom in the microwave. This way we donā€™t accidentally run the microwave with metal inside (the air fry addons) or run the oven with plastic inside like the steam accessory.

nVuln commented 1 year ago

Bug: this.courseDuration = this.createInputSourceService('Cycle Duration', 'CataNico-Always20', 4, this.courseTimeString, this.showTime); this.startTime.getCharacteristic(this.platform.Characteristic.ConfiguredName)

Correction: this.courseDuration = this.createInputSourceService('Cycle Duration', 'CataNico-Always20', 4, this.courseTimeString, this.showTime); this.courseDuration.getCharacteristic(this.platform.Characteristic.ConfiguredName).

I just fixed this and published new tag 1.6.0-test.2

carlosgamezvillegas commented 1 year ago

Hello nVuln,

I made some corrections and additions to the Dishwasher, Microwave, and Oven. Please see the latest version here.

ThinQ-07-12-2023.zip

Kind regards,

nVuln commented 1 year ago

@carlosgamezvillegas I just came back from business trip, I looked into your new code, just saw this function

udpServer() {
        this.server = udp.createSocket({ type: 'udp4', reuseAddr: true });
        this.server.on('error', (error) => {
            this.platform.log.debug(error);
            this.server.close();
        });
        // emits on new datagram msg
        this.server.on('message', (msg, info) => {
            let nest = msg.toString();
            // let nestMessage = JSON.parse(nest);
            if (nest.includes('temperature')) {
                // this.platform.log('Data from Nest: ', nest)
                // this.platform.log(typeof nest)
                nest = JSON.parse(nest);
                if (typeof nest?.temperature == 'number') {
                    this.localTemperature = 0.5 * Math.round(2 * nest?.temperature);
                }
                if (typeof nest?.humidity == 'number') {
                    this.localHumidity = Math.round(nest?.humidity);
                }
            }
            if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentTemperature).value !== this.ovenCurrentTemperature()) {
                this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.ovenCurrentTemperature());
            }
            if (this.ovenTempControl.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity).value !== this.localHumidity) {
                this.ovenTempControl.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.localHumidity);
            }
            // this.platform.log('Data from Nest (object): ', nestMessage)
        });
        //emits when socket is ready and listening for datagram msgs
        this.server.on('listening', () => {
            let address = this.server.address();
            let port = address.port;
            let family = address.family;
            let ipaddr = address.address;
            //this.platform.log('Microwave is listening at port ' + port);
            // this.platform.log('Oven ip ' + ipaddr);
            // this.platform.log('Oven is IP4/IP6 : ' + family);
        });

        //emits after the socket is closed using socket.close();
        this.server.on('close', () => {
            this.platform.log('Socket is closed !');
        });
        this.server.bind(1900, '239.255.255.250');
    }
carlosgamezvillegas commented 1 year ago

Hello nVuln,

Please ignore that update, I forgot to remove that. I use those lines to get the temperature readings from my Nest thermostat to use the values when the oven is not in use. I have a new version with more bug fixes anyway that I should be sending soon.

Kind regards,

carlosgamezvillegas commented 1 year ago

Hello nVuln,

Here are the latest updates to the Microwave, Oven, and Dishwasher. Hopefully I didn't miss anything this time. ThinQ-07-25-2023.zip

nVuln commented 1 year ago

I already updated your latest version, if everything working fine, I'll release it on next a few days

carlosgamezvillegas commented 1 year ago

Please use the latest version below. I corrected some typos. ThinQ-08-16-2023.zip

Kind regards,

nVuln commented 1 year ago

Please use the latest version below. I corrected some typos. ThinQ-08-16-2023.zip

Kind regards,

already applied this version too, hope everything working fine now