mitch7391 / homebridge-cmd4-AdvantageAir

Catered shell script to integrate air conditioner control units by Advantage Air into HomeKit using the plug-in homebridge-cmd4.
MIT License
38 stars 5 forks source link

[Beta] v3.3.0-beta Testing #45

Closed mitch7391 closed 2 years ago

mitch7391 commented 2 years ago

3.3.0-beta.2 (2022-02-18)

Special thanks to the amazing uswong and ztalbot2000 for adding these new features!

Notable Changes

Other Changes

Bug Fixes

mitch7391 commented 2 years ago

This issue has been created for discussions about the beta release and for people to report any issues found here. Please test it out and let me know what you think! For regular aircon users this should have no affect on your system and requires no changes on your part; but we want to hear if it does inadvertently affect anything as there has been a lot of under the hood changes. @parkertr @jhcloos @coolcaper777 @madtempest @8lackIce @cilibion @LukeDuring @rijidpish @GrossyGrosmann @jonalport @bullerdude @azzamaurice @cyrusauyeungc @antoniokly @lathiat @ryanbeaton @deathtrapz @hridaypats @assafw @ozbastion @nambour @MykMcC

For people with the MyPlace extras; you will now be able to add any lights or garage doors that you may have tied into your MyPlace system. @kaim2000 you are the only user besides @uswong's son that can test this for us; I hope you are still interested since you reached out to me on Reddit some time back.

lathiat commented 2 years ago

I’ve just built a place with MyPlace including the garage and 6 channel relay module (plus air as well with temp sensors to all 8 zones) though not moved in yet I have access so will try to get this tested. But no promises on an exact timeline.

mitch7391 commented 2 years ago

@lathiat we are pretty confident with what we have been testing on our own systems these past few weeks, it is just good to make sure the same is experienced by the community before it is pushed out as the stable version. Ung Sing who did the great majority of this work has a son with the MyPlace extras, who has been using it with no issues at present. So no rush, but thanks for reaching out!

Curious, what devices do you have connected to the relay kit?

coolcaper777 commented 2 years ago

Seems to be working fine here so far...

lathiat commented 2 years ago

Curious, what devices do you have connected to the relay kit?

5x lights most just a single baton a couple are a group of Downlights (just standard Clipsal units)

I believe the mygarage is connected to the 6th input/output. They have a new mygarage module that is its own extender unit but seems they used the old setup for my build. This is a standard “builder” pack they’re doing through a lot of builders so may be some more such users showing up soon.

I hope to add some mylights in a bit.

mitch7391 commented 2 years ago

Ahh no worries, was wondering if you may have some of the other devices added through the relay kit that we may have not added yet.

They have a new mygarage module that is its own extender unit but seems they used the old setup for my build.

Well let us know if the garage door does not work for you due to this and we can find a solution that works. Hopefully it just works as is :)

This is a standard “builder” pack they’re doing through a lot of builders so may be some more such users showing up soon.

Good to know! Thanks for the heads up. There were none of these cool options when I built sadly.

I hope to add some mylights in a bit.

Make sure you refer to the Wiki :)

kaim2000 commented 2 years ago

Hi Mitch, thanks so much for the update and sorry for not getting back to you on reddit - completely forgot I messaged you there. I'm having trouble getting it to work - I have no coding experience so please forgive me if I've made a silly mistake but I tried to get it working on one light, but when controlling from the Home app nothing happens. On homebridge when I check config it says all is good so I'm not really sure what's happening (I did have to add the word "timer" in the state_cmd_suffix field because when I simply had the light name the checker said missing timer). I checked the IP and light name and everything matches. I will attach the script I have.

{
    "bridge": {
        "name": "Homebridge",
        "username": "0E:AA:E6:59:B5:81",
        "port": 51124,
        "pin": "225-40-295"
    },
    "platforms": [
        {
            "platform": "Cmd4",
            "name": "Cmd4",
            "outputConstants": false,
            "statusMsg": true,
            "timeout": 60000,
            "stateChangeResponseTime": 0,
            "constants": [
                {
                    "key": "${IP}",
                    "value": "192.168.1.34"
                }
            ],
            "queueTypes": [
                {
                    "queue": "A",
                    "queueType": "WoRm"
                }
            ],
            "accessories": [
                {
                    "type": "Lightbulb",
                    "displayName": "Bed2lights",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Bed2lights",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Bed2lights' ${IP} timer"
                }
            ]
        },
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        }
    ],
    "accessories": []

The section at the bottom with name port and platform keeps coming back to my config file after deleting and rebooting so I assume it should be there.

Any help would be greatly appreciated.

kaim2000 commented 2 years ago

Sorry, not sure why the code came out looking like that. Attaching a file - hopefully it keeps formatting.https://drive.google.com/file/d/1UV2Ag-mGEmya8kZylOIIM05qAXXGRmVE/view?usp=sharing

mitch7391 commented 2 years ago

@kaim2000 your link doesn’t seem to work but I fixed the above config for you. The area you are talking about at the bottom is the config section for the Homebridge Web UI; it is meant to be there :)

Take timer out of your “state_cmd_suffix” and your light should work.

mitch7391 commented 2 years ago

Also ignore the shell check tool for these types of lights, I have forgot to update that check for these!

kaim2000 commented 2 years ago

Thanks so much Mitch. Unfortunately still not working. Nothing happens when I turn the light on/off in the home app. What's interesting is that the indicated dim level on the home app always moves when I change the dim level on the MyPlace app, but doesn't match it i.e. going from 100% to the lowest level on Myplace, Home app indicated going from 80% - 10%. So its definitely reading the light state from the MyPlace system (albeit somewhat inaccurately) but it doesn't seem to be able to push any changes to it. I also tried changing the timeout to 100 000 in case there was a poor connection but it didn't help

mitch7391 commented 2 years ago

That is interesting @kaim2000, we have not had dimming lights to test yet; but were able to build the code based on the API documents. We would have expected that to work properly. Can you confirm for me what the name of the light is in the MyPlace app?

kaim2000 commented 2 years ago

In the myplace app it's Bed2lights. Could I try configure as non dimmable?

mitch7391 commented 2 years ago

It is worth a try to see if that works. You will need to delete the Homebridge UI cache for that light in your Homebridge UI settings when you change the config for that light as it will think it is a still a dimmable one. You can find the steps in this comment if you are unsure how.

Thanks for confirming the name. I might have to defer you to @uswong then and see if he can help you out.

kaim2000 commented 2 years ago

Tried that now but unfortunately still doesn't work. Thanks for all your help so far though @mitch7391. Last question - do you think it could be my Homebridge install? Should I try reinstalling?

mitch7391 commented 2 years ago

Bugger, I wouldn’t expect Homebridge is the issue. Is this the only plug-in you have on Homebridge? Hopeful Ung Sing can spot something a bit easier than me and figure it out for you.

If you want, feel free to email my the data dump form the following command in your web browser:

http://192.168.1.34:2025/getSystemData

And email it to mitchwilliams7391@hotmail.com.

Make sure you take the time to check it for any sensitive data. I have not seen the MyPlace data dump and have heard it can contain some security details if you have the garage door or security system; please blank all of that out. The standard data dump I am used to seeing will contain your post code, latitude and longitude; blank those out too please. If you don’t feel comfortable sending it, that is also fine :) Ung Sing has done all of this work on his son’s system, so I have not seen a MyPlace data dump yet haha…

kaim2000 commented 2 years ago

@mitch7391 appreciate it. I sent you the data dump - if you can't find anything of use no worries. Looks very long - I wish you luck.

mitch7391 commented 2 years ago

I wonder if it is an issue with the naming, I know Ung Sing has tried to explain it to me a few times now. I see you have ‘Bed2lights’, ‘Bed2 Bath’ and ‘Bed2 Patio’; I wonder if it is getting confused with these. Thanks for sending this through, I’ll have to see if Ung Sing can help us out.

Also side note, I notice you have two aircons! We are going to have to add support for two at some point now haha…

mitch7391 commented 2 years ago

@kaim2000 I notice you have a garage door in your system too. Did you want to see if that one works?

kaim2000 commented 2 years ago

Thanks Mitch. Haha, I'm not too phased about the aircons at the moment.. but when you add them I'll be here. I'll test the garage door first thing in the morning and let you know

uswong commented 2 years ago

Good morning Mitch and @kaim2000,

I think the issue is the missing aircon system in the config.

If you can put back your aircon config especially the Thermostat, then it should work. If it still doesn't, then I will need to ask you for some other diagnostic file available in the directory /tmp

The MyPlace extras (lights and garage) are built on top of aircon system in this beta version.

The light naming above are good, no issue there. The config for the light itself without the timer looks ok too.

Cheers, Ung Sing

uswong commented 2 years ago

One other solution, Mitch, is to change the code a bit so that the MyPlace extras can be used independent of the aircon system.

mitch7391 commented 2 years ago

Oh good suggestion Ung Sing! I actually was not aware the new work was dependent of the aircon, but it makes sense. I had thought you are right, we should make it independent; but I think there is no need in the end. You will not have the MyPlace extras without the aircon. If you are buying this system and devices through Advantage Air, it is going to be a package deal or because you already have their aircon and want the extras in one place. If you wanted all of this stuff and did not already have the aircon; you would not consider Advantage Air at all for lights, garage doors, etc.

lathiat commented 2 years ago

That’s not true. My house was built by the builder with just lights and garage but no aircon. They have a control board without all the aircon bits for specifically doing that.

lathiat commented 2 years ago

FFD22359-F960-4119-B77C-C66019850E0A

mitch7391 commented 2 years ago

Well there you go :p I had seen on the website the parts were all separate but I had no idea they would sell these without the aircon! Thanks for letting us know Trent :)

uswong commented 2 years ago

okay, sounds like a good justification for me to make the MyPlace extras to be independent of the aircon.

mitch7391 commented 2 years ago

Agreed!

kaim2000 commented 2 years ago

Hi @uswong, thanks so much for all the help. Could you explain what you meant by "I think the issue is the missing aircon system in the config. If you can put back your aircon config especially the Thermostat, then it should work" - sorry, its probably quite simple but I'm struggling to follow. If you could let me know what to do that would be great. Also, in case that doesn't work, which diagnostic file would you need?

mitch7391 commented 2 years ago

Hi @kaim2000 Ung Sing means to add the Thermostat accessory to your config; as per the Wiki or the config samples. But if you hold off a little bit, I will roll out a change to the beta that Ung Sing has put together that should allow your lights to work without it.

kaim2000 commented 2 years ago

Hi @mitch7391, got some good news for once! This morning the light started working! Not sure what prompted that but yeah it was working as a simple light. I did just try change script back to a dimmable light though and now I'm getting a new error in homebridge terminal as shown in screenshot. Script seems to be all good so not sure what the issue is - have also attached a screenshot of the light script.

Lastly, my Garage door opener seems to have been installed with the states reversed (i.e. MyPlace app displays garage as open when it is closed and vice versa. Obviously this corresponds with the Home app which also says Open when it is closed. Is there something I could do to the script (flipping a 1 and 0 maybe?) to correct this for correct display in Home App? If there's no easy Fix I will get advantage air back here to correct it their side.

image image

kaim2000 commented 2 years ago

@mitch7391 Full config.json just in case:

{
    "bridge": {
        "name": "Homebridge",
        "username": "0E:B3:EA:DB:32:C2",
        "port": 51124,
        "pin": "662-37-163"
    },
    "platforms": [
        {
            "platform": "Cmd4",
            "name": "Cmd4",
            "outputConstants": false,
            "statusMsg": true,
            "timeout": 100000,
            "stateChangeResponseTime": 0,
            "constants": [
                {
                    "key": "${IP}",
                    "value": "192.168.1.34"
                }
            ],
            "queueTypes": [
                {
                    "queue": "A",
                    "queueType": "WoRm"
                }
            ],
            "accessories": [
                {
                    "type": "Lightbulb",
                    "displayName": "Bed2lights",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Bed2lights",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Bed2lights' ${IP}"
                },
                {
                    "type": "GarageDoorOpener",
                    "displayName": "Garage Door",
                    "obstructionDetected": "FALSE",
                    "currentDoorState": 0,
                    "targetDoorState": 0,
                    "name": "Garage Door",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Brand Name",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "currentDoorState"
                        },
                        {
                            "characteristic": "targetDoorState"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'thing:Garage' ${IP}"
                }
            ]
        },
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        }
    ],
    "accessories": []
}
mitch7391 commented 2 years ago

and now I'm getting a new error in homebridge terminal as shown in screenshot. Script seems to be all good so not sure what the issue is - have also attached a screenshot of the light script.

@kaim2000 it will be the same I had described before when you change the characteristics of an accessory (e.g from dimmable to simple light but keeps the same name); you will need to delete the Homebridge UI cache for that accessory to get rid of that error.

Is there something I could do to the script (flipping a 1 and 0 maybe?) to correct this for correct display in Home App?

Sounds like they have installed it the other way around to what we expected; I guess it is good to know that is possible. Might have to have a think about how to tackle this one.

mitch7391 commented 2 years ago

The beta has been bumped to v3.3.0-beta.3; this will now allow the MyPlace lights and garage door to be added without the aircon. This should only affect @kaim2000 and @lathiat at this stage and requires no changes form anyone. Just please report something if it seems off.

kaim2000 commented 2 years ago

@mitch7391 Hahah what a silly mistake! Thank you. Will let you know if it works

mitch7391 commented 2 years ago

You are not the first and definitely will not be the last to face that issue :p

kaim2000 commented 2 years ago

You are a wizard! Dimmable lights working!! (have also updated to new beta version). I will experiment with flipping some 1s and 0s in garage door config to see if anything works

mitch7391 commented 2 years ago

That is what I liked to hear :D from the getSystemData file you sent me, you have a lot of lights (98 from memory?) to add configs for and I do not envy that task hahaha play around and see if you can break anything and let us know what you find.

mitch7391 commented 2 years ago

Also the thanks goes to @uswong :p he is the one who did the work, I just was a part of the testing and published it!

kaim2000 commented 2 years ago

@uswong @mitch7391 both of you are incredible! My greatest thanks. Please let me know if I can ever provide you with more data from MyPlace system to help.

kaim2000 commented 2 years ago

Should I add multiple queues since there are so many lights? I saw in one of the previous forums you suggested to someone he add multiple queues due to having a lot of accessories. Adding everything on one queue now though and will check performance and revert

mitch7391 commented 2 years ago

Yep only use the one queue (A) and keep repeating the light accessory the 98 times with the correct names (that is going to be painful). A quick emaple here:

{
    "bridge": {
        "name": "Homebridge",
        "username": "0E:B3:EA:DB:32:C2",
        "port": 51124,
        "pin": "662-37-163"
    },
    "platforms": [
        {
            "platform": "Cmd4",
            "name": "Cmd4",
            "outputConstants": false,
            "statusMsg": true,
            "timeout": 100000,
            "stateChangeResponseTime": 0,
            "constants": [
                {
                    "key": "${IP}",
                    "value": "192.168.1.34"
                }
            ],
            "queueTypes": [
                {
                    "queue": "A",
                    "queueType": "WoRm"
                }
            ],
            "accessories": [
                {
                    "type": "Lightbulb",
                    "displayName": "Bed2lights",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Bed2lights",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Bed2lights' ${IP}"
                },
                {
                    "type": "Lightbulb",
                    "displayName": "Light2",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Light2",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Light2' ${IP}"
                },
                {
                    "type": "Lightbulb",
                    "displayName": "Light3",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Light3",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Light3' ${IP}"
                },
                {
                    "type": "Lightbulb",
                    "displayName": "Light4",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Light4",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Light4' ${IP}"
                },
                {
                    "type": "Lightbulb",
                    "displayName": "Light5",
                    "on": "FALSE",
                    "brightness": 50,
                    "name": "Light5",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Down Lights",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "on"
                        },
                        {
                            "characteristic": "brightness"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'light:Light5' ${IP}"
                },
                {
                    "type": "GarageDoorOpener",
                    "displayName": "Garage Door",
                    "obstructionDetected": "FALSE",
                    "currentDoorState": 0,
                    "targetDoorState": 0,
                    "name": "Garage Door",
                    "manufacturer": "Advantage Air Australia",
                    "model": "MyPlace",
                    "serialNumber": "Brand Name",
                    "queue": "A",
                    "polling": [
                        {
                            "characteristic": "currentDoorState"
                        },
                        {
                            "characteristic": "targetDoorState"
                        }
                    ],
                    "state_cmd": "'/usr/local/lib/node_modules/homebridge-cmd4-advantageair/AdvAir.sh'",
                    "state_cmd_suffix": "'thing:Garage' ${IP}"
                }
            ]
        },
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        }
    ],
    "accessories": []
}

Any that throw errors, I would be checking for copy/paste mistakes. Remember two accessories cannot have the exact same name.

uswong commented 2 years ago

Lastly, my Garage door opener seems to have been installed with the states reversed (i.e. MyPlace app displays garage as open when it is closed and vice versa. Obviously this corresponds with the Home app which also says Open when it is closed. Is there something I could do to the script (flipping a 1 and 0 maybe?) to correct this for correct display in Home App?

It is wonderful to hear that lights and garage door are working for @kaim2000 now.

The garage door state is a funny one on HomeKit. 1 means close and 0 means open while within MyPlace 0 means close, 100 means open. So I have to set the value to 100 when the command coming from the homekit with a value of 0. So if your MyPlace app also displays the reverse then it is the setting within MyPlace equipment needs to be changed.

The MyPlace system I was testing on had the setting done correctly.

image

mitch7391 commented 2 years ago

Further to what Ung Sing has said above, this is what the Advantage Air API document for myThings states:

Note that value 100 is used to assign Button position to Up, On or Open. Whereas value 0 is used to assign button position to Down, Off or Close. Values other than 0 or 100 are not supported and ignored

So it sounds very likely it was installed incorrectly. However, if this is an issue that is faced commonly (or too much trouble for installer to set it right), we could add a flip constant to the "state_cmd_suffix" to used flipped values in the script. I am just spit-balling here, but unless I have overlooked something silly that could be possible.

uswong commented 2 years ago

Is there something I could do to the script (flipping a 1 and 0 maybe?) to correct this for correct display in Home App?

If you just want to have the homekit to display correctly for now and not too worry about what MyPlace App is showing, then indeed you can do something with the script yourself:

edit AdvAir.sh of v3.3.0-beta3 change line 716 from echo 0 to echo 1 and change line 719 from echo 1 to echo 0 save your edited file

That will be it.

uswong commented 2 years ago

we could add a flip constant to the "state_cmd_suffix" to used flipped values in the script.

That is indeed something we can consider to do.

mitch7391 commented 2 years ago

then indeed you can do something with the script yourself

You would need to apply that change each time there is an update though as it gets wiped by the update; just a heads up for the time being.

kaim2000 commented 2 years ago

Thank you! I will try that and revert

kaim2000 commented 2 years ago

one weird issue -- two lights seem to be presenting issues. They both work when controlling from the Home App but seem to be presenting issues in Homebridge terminal. Could it be poor wifi connection to the MyPlace tablet? Sometimes when turning lights on/off using Home App it takes 5-10 seconds for the light to actually turn on or off image

kaim2000 commented 2 years ago

@uswong thank you so much for suggestion on fixing garage door state in Home App - That worked!