Driver for Gas Sensor

Ping me in a couple of weeks, hopefully I'll be caught up by then...

OK. Thanks. It's not supposed to be delivered until next week. It does sound like a useful device type.

I just got my gas detector. Anything I can do to help out? I got this one.

I just brought this gas detector from Amazon that @razorwing shows in the post above and borrow a device driver and it shows up as Heiman Gas sensor. I haven't tested it but the green light is on and steady. It seems to be working.

What device driver did you use?

I have one going. Seems to be working for me so far. Haven't test with actual gas yet. I am sure the driver could use some work.

Updated 7/21: Changed smoke status from "cleared" to "clear".

/**
 *  Heiman Natural Gas Sensor
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */


import hubitat.zigbee.clusters.iaszone.ZoneStatus
 
metadata {
	definition (name: "Heiman Gas Detector", namespace: "hubitat", author: "cuboy29") {
		
        capability "Configuration"
        capability "SmokeDetector"
        capability "Sensor"
        capability "Refresh"
              
        attribute "smoke", "string"
        
		fingerprint profileID: "0104", deviceID: "12", inClusters: "0000,0003,0500,0009", outClusters: "0003,0019"      
    }
}
 
def parse(String description) {
    
	//log.debug "description: $description"
    def descMap = [:]
    
	if (description?.startsWith('zone status')) {
			descMap = parseIasMessage(description)
    }else if (description?.startsWith('enroll request')) {
		    List cmds = zigbee.enrollResponse()
		    descMap = cmds?.collect { new hubitat.device.HubAction(it) }
	}else if (description?.startsWith('catchall')) {
            descMap = parseCatchAllMessage(description)
    }else if (description?.startsWith('read attr'))  {  
            descMap = zigbee.parseDescriptionAsMap(description)
       
            if ((descMap?.cluster == "0500" && descMap.attrInt == 0x0001) && (descMap.value == '002B')){  //Zone Type
                log.debug "Zone Type is Carbon Monoxide (CO) Sensor"
			}else if ((descMap?.cluster == "0500" && descMap.attrInt == 0x0000) && (descMap.value == '01')){  //Zone State
                log.debug "Zone State is enrolled"
			}else if ((descMap?.cluster == "0500" && descMap.attrInt == 0x0002) && ((descMap.value == '0030') || (descMap.value == '0020'))){  //Zone Status
                log.debug "${device.displayName} is cleared"
            }else if (descMap?.cluster == "0000" && descMap.attrInt == 0x0004){  //Manufacture
                sendEvent(name: "manufacture", value: descMap.value)
            }else if (descMap?.cluster == "0000" && descMap.attrInt == 0x0005){  //Model 
                sendEvent(name: "model", value: descMap.value)
            }
	}

	//def result = descMap ? createEvent(descMap) : [:]	
	return descMap   
}    


private Map translateZoneStatus(ZoneStatus zs) {
	// Some sensor models that use this DTH use alarm1 and some use alarm2 to signify motion       
	return getGasResult(zs.isAlarm1Set() || zs.isAlarm2Set())
}

private Map getGasResult(value) {

    def descriptionText = value ? "${device.displayName} has detected GAS!" : "${device.displayName} is clear!"
    log.debug descriptionText
	return [
			name			: 'smoke',
			value			: value ? 'detected' : 'clear',
            isStateChange: true,
			descriptionText : descriptionText
	]
}

private parseCatchAllMessage(String description) {
    
    Map resultMap = [:]
    def descMap = zigbee.parse(description)  
    //log.debug descMap.inspect()
    return resultMap
}

private Map parseIasMessage(String description) {
    
    ZoneStatus zs = zigbee.parseZoneStatus(description)    
    translateZoneStatus(zs)    
}

def refresh() {
    
	log.debug "Refreshing..."
	def refreshCmds = []
    
    refreshCmds +=
	zigbee.readAttribute(0x0500, 1) +	// IAS ZoneType
    zigbee.readAttribute(0x0500, 0) +	// IAS ZoneState
    zigbee.readAttribute(0x0500, 2) +	// IAS ZoneStatus
    zigbee.readAttribute(0x0000, 7) +	// power source
    //zigbee.readAttribute(0x0009, 7) +	// not sure what this cluster do yet
    zigbee.readAttribute(0x0000, 4) +	// manufacture
    zigbee.readAttribute(0x0000, 5) +	// model indentification
        zigbee.enrollResponse()
    
	return refreshCmds
}

def configure() {
    
    log.debug "Configuring..."
    
    def cmds = [
            //bindings
            "zdo bind 0x${device.deviceNetworkId} 1 1 0x0500 {${device.zigbeeId}} {}", "delay 200",
        ] +  zigbee.enrollResponse(1200) + refresh()
    
    return cmds
}
3 Likes

Now I using the one @cuboy29 just listed as it seems to be better.

All I am getting is the model and Manuf. in the Current States. After pressing test button I get Smoke: Cleared

EDIT: Anyone seen this?

OR This:

I wonder if this is the one that works with this driver:

One critical piece of information about this device, if someone could help me.

How often does this device "check in"?
The reason why I find that to be important is that I can test pro grammatically when the device has "checked in". If it misses too many check in's, it probably has dropped from the mesh. Correct?

I am getting this weird stuff in the logs. It repeats these.

dev:2072019-07-19 09:32:30.724 am debugRefreshing...

dev:2072019-07-19 09:32:02.922 am debugNatural Gas Detector is cleared

dev:2072019-07-19 09:32:00.910 am debugZone State is enrolled

dev:2072019-07-19 09:32:00.742 am debugNatural Gas Detector is cleared

dev:2072019-07-19 09:31:58.916 am debugZone Type is Carbon Monoxide (CO) Sensor

dev:2072019-07-19 09:31:58.836 am debugRefreshing...

dev:2072019-07-19 09:31:58.738 am debugZone State is enrolled

dev:2072019-07-19 09:31:56.737 am debugZone Type is Carbon Monoxide (CO) Sensor

dev:2072019-07-19 09:31:54.012 am debugRefreshing...

dev:2072019-07-19 09:31:53.968 am debugConfiguring...

dev:2072019-07-17 04:31:19.494 pm debugNatural Gas Detector, parse description: catchall: 0000 8032 00 00 0040 00 8855 00 00 0000 00 00 00000A0109000003000000000300000000030000000003000000000300000000030000000003000000000300000000030000

dev:2072019-07-17 03:31:52.739 pm debugNatural Gas Detector, parse description: catchall: 0000 0006 00 00 0040 00 8855 00 00 0000 00 00 01FDFF040101190000

it seems to check in every 30 minutes.

image

I'm getting the 30 minutes check in also but not the other that @razorwing is getting? @razorwing did you go into device and click the configure and refresh button ?

Several times, and pressed the test button. There is a reset on the side, I might try that.

EDIT: I did a reset on it and discover and it said it found a previous device, which is correct. I did a configure and refresh again and got the same result. Smoke: Cleared

What are you expecting to see?

Something about the gas would be nice since it is not a smoke detector. I mean this in a nice way.

Ahh the problem is Hubitat does not have Gas as a capabilities. I don't see the need to have it be gas detector as long as the sensor trips and report the event. You can program RM to say what ever you want.

Have you or anyone verified that it does trip with natural gas? Or propane? Although that would be very dangerous. I guess it is one of those things we take on faith.

I am waiting for @ritchierich to do the test. He has a way to do it with propane safely outdoor. I hope he brings good news soon.

@bravenel Is there a way to add a gas capability to HE for this gas detector and others? Thanks

That's the reason to have Mike Maxwell involved. He mentioned he thought he could start looking at it in a couple of weeks.