New Gree Air Conditioner Binding

I uploaded a new build. I changed the mode channel to Strong supporting the following mode

  • auto
  • cool
  • dry
  • fan
  • heat

extensiosn:

  • eco: new: set A/C to cool and enable powersave
  • turbo: new: set A/C to fan and turn on turbo

power (maybe I remove the power channel)

  • on: switch A/C on, do not change the other settings
  • off: switch A/C off, do not change the other settings

In general the A/C is turned on before the mode is selected (except on off mode).

The binding should also support backward compatibilty: If you replace the jar it should still show the mode channel type as Number and accepts Numbers - please verify.
When you delete and re-discover the thing you should see mode as Strong type. This will then accept the new mode strings. In addition to the above you could also send “0”…“4” or another number to give transparent access to the unit.

Numbers coming back from the unit will be mapped to the above mode values.

Please perform the following test

  • replace the jar
  • do test with mode as Number
  • delete thing
  • re-discover
  • send text values to mode channel
  • GA test

Thanks for supporting with testing. I think my unit gets installed in 6 weeks so I can’t do testing myself.

Both numbers and string mode are working now.
Here is the log of the string mode:

2020-05-03 22:07:30.715 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command on�to channe mode
2020-05-03 22:07:30.728 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode on mapped to -1
2020-05-03 22:07:42.109 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command auto�to channe mode
2020-05-03 22:07:42.109 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode auto mapped to 0
2020-05-03 22:07:42.109 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Send Auto-ON for mode 0
2020-05-03 22:07:42.122 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Select mode 0
2020-05-03 22:07:45.086 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 26�to channe temperature
2020-05-03 22:07:45.867 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 27�to channe temperature
2020-05-03 22:07:49.590 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command cool�to channe mode
2020-05-03 22:07:49.590 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode cool mapped to 1
2020-05-03 22:07:49.590 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Send Auto-ON for mode 1
2020-05-03 22:07:49.603 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Select mode 1
2020-05-03 22:07:52.886 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 26�to channe temperature
2020-05-03 22:07:53.711 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 25�to channe temperature
2020-05-03 22:07:54.345 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 24�to channe temperature
2020-05-03 22:07:58.644 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command dry�to channe mode
2020-05-03 22:07:58.644 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode dry mapped to 2
2020-05-03 22:07:58.644 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Send Auto-ON for mode 2
2020-05-03 22:07:58.658 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Select mode 2
2020-05-03 22:08:01.412 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 25�to channe temperature
2020-05-03 22:08:02.636 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Executing automatic update of values
2020-05-03 22:08:02.636 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Fetching status values from device.
2020-05-03 22:08:02.652 [TRACE] [ree.internal.discovery.GreeAirDevice] - Response from device: {"t":"dat","mac":"2059a0b49c2f","r":200,"cols":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt","NoiseSet"],"dat":[1,2,25,1,0,0,1,0,1,0,3,0,0,0,0,0,0,0,0]}
2020-05-03 22:08:02.652 [TRACE] [ng.gree.internal.handler.GreeHandler] - Updating channel power : ON
2020-05-03 22:08:02.653 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Updading mode channel with 2/dry
2020-05-03 22:08:02.653 [TRACE] [ng.gree.internal.handler.GreeHandler] - Updating channel mode : dry
2020-05-03 22:08:06.211 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command fan-only�to channe mode
2020-05-03 22:08:06.211 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode fan-only mapped to 3
2020-05-03 22:08:06.211 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Select mode 3
2020-05-03 22:08:11.484 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command 24�to channe temperature
2020-05-03 22:08:16.041 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command heat�to channe mode
2020-05-03 22:08:16.041 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode heat mapped to 4
2020-05-03 22:08:16.041 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Select mode 4
2020-05-03 22:08:24.257 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Issue command off�to channe mode
2020-05-03 22:08:24.275 [DEBUG] [ng.gree.internal.handler.GreeHandler] - Mode off mapped to -1

All modes are working including on and off.
Autodiscovery as well.
In numbers on/off is not working, but in string mode -1 is visible.
So I tried to move back to Numbers and try -1 but no success. Mode change was not working at all.
Then I tried delete, rediscover but it didn’t help.
So I changed back to String and it works again.
Untitled-1.log (36.1 KB)

there is no number for on/off so this can‘t work

did you tried

  • having a thing with channel type Numbet
  • sendCommand(itemMode, 0)

In fact there is no need to backward compatibility, because I renamed the binding

I’ve already deleted older vesion of binding Greeair and use only this one. But you’ve right, I’ve forgotten about strong mode. That could be the reason that I couldn’t use my older code. Anyway it works perfect and I will try strong mode as well. GA connection works as well seamless. What I’m working on to make working all modes of the binding. Theoretically all modes are avaiable in GA now, but it takes time as this is brand new developments in GA even for Google itself and thermostat set up a little bit tricky.

I’m not expert of Github. But I tried to save the changes:

I use sitemap when I control my AC or Googlehome.
String version:
Items:

Group Gree_Modechannel "Gree" { ga="Thermostat"  [modes="auto,cool,dry,fan-only,heat,on,off"] } // új Gree bindinggal

Switch   GreePower           "Power"                                     {channel="gree:airconditioner:2059a0b49c2f:power" }
        String   GreeMode_GA         "Gree mode"             (Gree_Modechannel)  { ga="thermostatMode" }   
        String   GreeMode            "Gree mode"             (Gree_Modechannel)  {channel="gree:airconditioner:2059a0b49c2f:mode" }

Sitemap:

Selection label="Mód [%s]" item=GreeMode mappings=["auto"="Auto", "cool"="Cool", "dry"="Dry", "fan-only"="Fan", "heat"="Heat", "on"="On", "off"="Off"] icon=fan_box
							

Number Version:
Items:

Group Gree_Modechannel "Gree" { ga="Thermostat"  [modes="auto,cool,dry,fan-only,heat,on,off"] } // új Gree bindinggal

Switch   GreePower           "Power"                                     {channel="gree:airconditioner:2059a0b49c2f:power" }
        String   GreeMode_GA         "Gree mode"             (Gree_Modechannel)  { ga="thermostatMode" }   
        Number   GreeMode            "Gree mode"             (Gree_Modechannel)  {channel="gree:airconditioner:2059a0b49c2f:mode" }

Sitemap:

Selection label="Mód [%s]" item=GreeMode mappings=[0="Auto", 1="Cool", 2="Dry", 3="Fan", 4="Heat", 12="On", 11="Off"] icon=fan_box

When I turned back item to Number and change to this sitemap line, mode change was not working from my Sitemap. Can it have connection to Stronge mode? Anyway String version is perfect.
Group item is required for Googlehome connection as I wrote before.

There is a rule behind for Googleassitant link what is translating between binding and GA:

rule "Translate Mode from GA 2"
    when
         Item GreeMode_GA changed
    then        
        if(GreePower.state == OFF) {
            sendCommand(GreePower,ON)
        }
        if(GreeMode_GA.state == "auto" ) {
          sendCommand(GreeMode,0) 
         }
        if(GreeMode_GA.state == "cool" ) {
            sendCommand(GreeMode,1)
         }
         if(GreeMode_GA.state == "dry" ) {
            sendCommand(GreeMode,2) 
         }
         if(GreeMode_GA.state == "fan-only" ) {
            sendCommand(GreeMode,3) 
         }
        if(GreeMode_GA.state == "heat" ) {
            sendCommand(GreeMode,4)
         }
        if(GreeMode_GA.state == "off" ) {
            sendCommand(GreePower,OFF)
         }
end

Google Assistant controls now all 4 modes, on/off with that rule with above string version set up including Group Item. Avaiable modes set up is at Group Item level and works. It can change temperature as well.

I think fan speed can be controlled with it as well. I’ll check it later this week.

1 Like

@markus7017

If you have a A/C on a different subnet just add the Thing manually. I changed the code already that there is no discovery if IP address is specified. Discovery only takes place when discovering a thing from the Inbox, so longer on Thing initialization.

I didn’t write it precisely. I do not mean Auto Discover in Paper UI but SCAN in binding which is used to generate key.

Check file: bundles/org.openhab.binding.gree/src/main/java/org/openhab/binding/gree/internal/discovery/GreeDeviceFinder.java

public GreeDeviceFinder(String broadcastAddress) throws UnknownHostException {
    mIPAddress = InetAddress.getByName(broadcastAddress);
}

I will try install your binding on weekend.

Just wanted to say, stumbled across this thread and binding. Got 2.4 installed on openhab (latest from apt) and works a treat. Very many thanks for sharing.
Just need to sort out some transforms/enums for the modes etc and I’ll be a very happy bunny!
Cheers
PS: Doing everything with config files rather than through PaperUI

:+1:

Hi Marcus,
Thanks for sharing this. Perfect job!

One comment from my side.
I am new in openHub, but I think I’ve found a slight mistake.
After adding things in automatic way with Simple Mode item linking switched on, the dry mode item is described as “Turbo mode” and real turbo mode is described as “Turbo”.
You can check it in attached print screen.

Regards
Krzysiek

openHab_green

Please don‘t use simple mode, it is deprecated and will disappear with openHAB 3.0
It was causing many problems for several users.

Thanks for advice. I try to not use it, but with this binding was better for me to initiate the items with “Simple mode”.
Maybe worth to mention it also on “instalation manual”, because there is still recomendation to use “Simple mode” :slight_smile:

Hi,

I need two items for GREE Standard:

  • Quiet (values: 0-2)
  • SwingLfRig (values: 0-6)

I’ve traced and got:

2020-05-26 23:09:57.221 [TRACE] [ree.internal.discovery.GreeAirDevice] - Response from device: {“t”:“dat”,“mac”:“f4911e8ea8f4”,“r”:200,“cols”:[“Pow”,“Mod”,“SetTem”,“WdSpd”,“Air”,“Blo”,“Health”,“SwhSlp”,“Lig”,“SwingLfRig”,“SwUpDn”,“Quiet”,“Tur”,“StHt”,“TemUn”,“HeatCoolType”,“TemRec”,“SvSt”,“NoiseSet”],“dat”:[1,1,16,1,0,0,1,0,1,6,2,2,0,0,0,0,0,0,0]}

Can you add it, rebuild and put new snapshot? I’ve modified files (attached), but I’m not sure if it’s proper.GreeAirBindingConstants.java.txt (3.5 KB) GreeAirHandler.java.txt (22.2 KB)

Hi,

I installed the Gree bindings for my new Sinclair MV-H09BIS air condition on a new installed openHAB 2.5.5-1 with the actual version org.openhab.binding.gree-2.5.5-SNAPSHOT.jar. Everything works fine, except adjusting the temperature. In the log, I find following exception:

19:24:56.848 [DEBUG] [ing.gree.internal.handler.GreeHandler] - Fetching status values from device.
19:24:56.880 [TRACE] [gree.internal.discovery.GreeAirDevice] - Response from device: {"t":"dat","mac":"f4911ebadf74","r":200,"cols":["Pow","Mod","SetTem","WdSpd","Air","Blo","Health","SwhSlp","Lig","SwingLfRig","SwUpDn","Quiet","Tur","StHt","TemUn","HeatCoolType","TemRec","SvSt","NoiseSet"],"dat":[0,0,25,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0]}
19:25:55.908 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'KlimaVorraum_Temperatur' received command 22
19:25:55.957 [INFO ] [arthome.event.ItemStatePredictedEvent] - KlimaVorraum_Temperatur predicted to become 22
19:25:55.995 [INFO ] [smarthome.event.ItemStateChangedEvent] - KlimaVorraum_Temperatur changed from 25.0 °C to 22.0 °C
19:25:55.995 [DEBUG] [ing.gree.internal.handler.GreeHandler] - Issue command 22 °C to channe temperature
19:25:56.005 [DEBUG] [ing.gree.internal.handler.GreeHandler] - Unable to execute command 22 °C for channel temperature
java.lang.ClassCastException: org.eclipse.smarthome.core.library.types.QuantityType cannot be cast to org.eclipse.smarthome.core.library.types.DecimalType
        at org.openhab.binding.gree.internal.handler.GreeHandler.handleCommand(GreeHandler.java:165) [bundleFile:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
        at com.sun.proxy.$Proxy140.handleCommand(Unknown Source) [?:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_252]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_252]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_252]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_252]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_252]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_252]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_252]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]

I’m not a developer, so I don’t know what’s going on. The configuration is done in the PaperUI. Is there an error in the configuration?

Paper UI

Best regards
Gerald

you need to send 22, not 22°C

Looking to the channel definitions I can’t confirm this.

	<channel-type id="dry">
		<item-type>Switch</item-type>
		<label>Dry</label>
		<description>Set on/off the Air Conditioner's Dry function if applicable to the Air Conditioner model .</description>
	</channel-type>

	<channel-type id="turbo">
		<item-type>Switch</item-type>
		<label>Turbo</label>
		<description>Set on/off the Air Conditioner's Turbo mode.</description>
	</channel-type>

It seems that you are using the old code base. Check this one:
https://github.com/markus7017/openhab-addons/tree/gree_snapshot/bundles/org.openhab.binding.gree

Please provide descriptions of

  • Quiet (values: 0-2)
  • SwingLfRig (values: 0-6)

try this build.

  • I renamed the channel swingvertical into swingUpDown
  • I added channel swingLeftRight and quiet

new build: https://github.com/markus7017/myfiles/blob/master/gree/org.openhab.binding.gree-2.5.5-SNAPSHOT.jar?raw=true

you need to delete and re-discover the thing(s)

UPDATE:
guys, I need your help: I made various changes driven by the PR review. I need to know if this doesn’t impacted the functionality before moving one. It doesn’t make sense to make a lot of changes and somewhen (due to a typo) it breaks and diagnosis will be hard.

@vespaman @Daya84 @kovacsi2899 @Piotras @GreenaGiant @smarthomepch @orzechszek and all others:
So could you please verify the current DEV build (Discovery + all functions), so I could move to the next round.

Thank you, now it works

Hi,

Left/Right works fine. Up/Down stopped reacting.
For ‘quiet’ I get:

Exception while formatting value ‘ON’ of item AirconQuiet with format ‘%.0f’: f != java.lang.String

Quiet (values: 0-2)
0 - OFF
1 - Auto Quiet
2 - Quiet

SwingLfRig (values: 0-6)
0 - OFF
1 - Full
2 - Left
3 - Mid-Left
4 - Middle
5 - Mid-Right
6 - Right

‘Dry’ channel still named: “Turbo Mode” - needs update

did you deleted & re-discovered the thing?
did you noticed that channel swingvertical was renamed into swingUpDown? (as noted above)
in my setp “dry” is Dry Mode and “turbo” is “Turbo Mode” as described in the thing xml

Please re-test, I added support for Temp as QuantityType