[Release] HubDuino v1.1.9 - Hubitat to Arduino / ESP8266 / ESP32 / ThingShield Integration (ST_Anything)

That is a great question. The reason I have included various third-party libraries is two-fold:

  1. Make sure I have a copy of the code in the event the developer were to remove it from GitHub
  2. The versions included have been tested and are known to work with the HubDuino libraries.

Thanks!

In relation to the Contact Sensor device handler im trying to find a way to change the displayed state from "Open" or "Closed" to something else like "Alarm" and "Normal". Im not sure where to begin editing the driver to modify this?

In general, HubDuino implements Hubitat’s standard device capabilities. Obviously, you’re welcome to change things as you see fit for your needs.

If you’re using the released version of HubDuino and ST_Anything, the you should be able to copy and modify the Child Contact Sensor custom driver. After creating a new version, you could change the child device’s driver type to your new one.

The section of code you’d modify the following section.

def parse(String description) {
    if (logEnable) log.debug "parse(${description}) called"
	def parts = description.split(" ")
    def name  = parts.length>0?parts[0].trim():null
    def value = parts.length>1?parts[1].trim():null
    if (name && value) {
        // Update device
        sendEvent(name: name, value: value)
    }
    else {
    	log.error "Missing either name or value.  Cannot parse!"
    }
}

You could add a custom attribute to your version of driver, and then add your custom sendEvent() using your custom text.

Thanks very much for the quick reply, im very new at coding, I've been able to create a custom attribute by dumb luck mostly. what line would i need to add to the existing code. Or is there a reference document that i can research to work through this. Best i can come up with would be this:

def value = if open=Alarm, if closed=Normal?

I found some code for a konnected contact sensor that does this but it seems its getting some info from its parent app:

metadata {
capability "Water Sensor"
capability "Sensor"
}
preferences {
input name: "normalState", type: "enum", title: "Normal State",
options: ["Normally Closed", "Normally Open"],
defaultValue: "Normally Open",
description: "Most leak sensors indicate water when the circuit is closed (NO). Select Normally Closed (NC) to reverse this logic."
}
}

def isClosed() {
normalState == "Normally Closed" ? "dry" : "wet"
}

def isOpen() {
normalState == "Normally Closed" ? "wet" : "dry"
}

//Update state sent from parent app
def setStatus(state) {
def stateValue = state == "1" ? isOpen() : isClosed()
sendEvent(name: "water", value: stateValue)
log.info "$device.label is $stateValue"
}

What is the name of your custom attribute? Did you declare the custom attribute within the driver? What data type did you choose for it?

The change would be something like the following, assuming your custom attribute name is "AlarmStatus"

def parse(String description) {
    if (logEnable) log.debug "parse(${description}) called"
	def parts = description.split(" ")
    def name  = parts.length>0?parts[0].trim():null
    def value = parts.length>1?parts[1].trim():null
    if (name && value) {
        // Update device
        sendEvent(name: name, value: value)

       //Start of new Code for custom attribute
        if (value == "open") {
            sendEvent(name: "AlarmStatus", value: "Alarm")
        }
        else {
            sendEvent(name: "AlarmStatus", value: "Normal")
        }
       //end of new code

    }
    else {
    	log.error "Missing either name or value.  Cannot parse!"
    }
}

Was throwing an error because the IF command was uppercase but now i got it working. Thank you very much for this and the entire HubDuino platform its very useful.

I'm using a Mega with 12 sensors and 4 switches going in to enable and monitor my in floor radiant heating system and mechanical equipment, so for the contact sensors i didn't want to figure out which state is which since some of the device contacts are normally open and some are normally closed. This will also work nicely with displaying any custom state like Wet/Dry, ect

If anyone wants this for the future full code is below:

/**

  • Child Contact Sensor
  • Copyright 2017 Daniel Ogorchock
  • 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.
  • Change History:
  • Date Who What

  • 2017-04-10 Dan Ogorchock Original Creation
  • 2017-08-23 Allan (vseven) Added a generateEvent routine that gets info from the parent device. This routine runs each time the value is updated which can lead to other modifications of the device.
  • 2018-06-02 Dan Ogorchock Revised/Simplified for Hubitat Composite Driver Model
  • 2018-09-22 Dan Ogorchock Added preference for debug logging
  • 2019-07-01 Dan Ogorchock Added importUrl
  • 2020-01-25 Dan Ogorchock Remove custom lastUpdated attribute & general code cleanup

*/
metadata {
definition (name: "Child Contact Sensor", namespace: "ogiewon", author: "Dan Ogorchock", importUrl:

	capability "Contact Sensor"
	capability "Sensor"
    
    attribute "AlarmStatus", "String"
}

preferences {
    input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
}

}

def logsOff(){
log.warn "debug logging disabled..."
device.updateSetting("logEnable",[value:"false",type:"bool"])
}

def parse(String description) {
if (logEnable) log.debug "parse(${description}) called"
def parts = description.split(" ")
def name = parts.length>0?parts[0].trim():null
def value = parts.length>1?parts[1].trim():null
if (name && value) {
// Update device
sendEvent(name: name, value: value)

   //Start of new Code for custom attribute
    if (value == "open") {
        sendEvent(name: "AlarmStatus", value: "Alarm")
    }
    else {
        sendEvent(name: "AlarmStatus", value: "Normal")
    }
   //end of new code

}
else {
	log.error "Missing either name or value.  Cannot parse!"
}

}

def installed() {
updated()
}

def updated() {
if (logEnable) runIn(1800,logsOff)
}

Has anything changed with ESP8266 OTA updates in the Arduino IDE? I used to be able to update mine over the air but noticed they no longer show up in my port list within the IDE. I am still using 1.x vs 2 FYI if that makes a difference.

I am not aware of any changes, and I did use Arduino IDE v1.8.19 the last time I performed an OTA upgrade just a few weeks ago. I consolidated two HE hubs into one new C-8 Pro hub. I had to change the IP address of the Hub in a couple of my sketches. It worked fine.

By any chance, has the computer you're running the Arduino IDE on changed since the last time you tried using OTA updates? I can't recall the details, but I do seem to recall that a local install of Python may have been required to use the OTA update feature that a community member added to the project many years ago. If you're trying a new computer, maybe it is missing a pre-requisite? :thinking:

Yep me too though consolidating 4 hubs into 2 Pros.

I tried on 2 separate Windows 11 machines and nothing has changed with them and I don’t believe I have Python installed on either even prior when it was working.

Fortunately I haven’t had to update these devices in a long while but just noticed the devices didn’t show up hence my question. So no worries!

1 Like

I am also running Windows 11. I just checked my list of installed software and I do see the following...

Not 100% that this would fix it for you, but it may be worth a try. :wink:

1 Like

Just installed the same version of Python and it didn’t resolve the issue. But all good. I appreciate the suggestion.

1 Like

I'm working on an ESP32 based Hubduino sketchwhich will use both BT and Wifi (BT Tile Presence).
It compiles fine but when it runs, I get this:
11:00:05.802 -> ESP32 station start
11:00:05.802 -> E (3785) wifi:Error! Should enable WiFi modem sleep when both WiFi and Bluetooth are enabled!!!!!!
11:00:05.802 ->
11:00:05.802 ->
11:00:05.802 -> abort() was called at PC 0x401c0ceb on core 0

... then it continually reboots with that message.

I know that there are native ESP32 ways of sleeping and waking WiFi but since WiFi seems to be managed by SmartThings, I don't think that it will work.

  • Is there a way that this can be accomplished?

BTW: Boards I've tried are ESP32-WROOM-DA and Lolin D32 .

I've seen that problem when I played with BT and Wifi with a ESP32. I believe that you have to manage the two radios so they do not attempt to transmit at the same time. One radio sleeps while the other can use the transmittter/antenna then do that to the other radio. That would have been a very complicated and/or compromised application for me so I stopped digging into it.

I have never tried using Bluetooth and WiFi on an ESP32 at the same time with HubDuino.

It looks like someone has done it, based upon this thread: Tile Trackers - #12 by scottmil
I didn't see anything there about turning radios/modems on or off.
He used a Adafruit Huzzah32, which I don't have. Perhaps there is something magical in that ESP32 implementation, so I will order one and see if I have any luck.

If that's not successful, I can go with the approach of using an external BT/BLE module. However, I like the self contained approach - especially where I will need 3 of these things around the house.

1 Like

I can confirm that the Adafruit Huzzah32 has the same restriction as any of the other ESP32 boards. I've been in contact with the author of the Tile Trackers project mentioned above (scottmil) and he used a 2 board approach - one for BLE and the other for HubDuino.
Meanwhile, I'm going to go the route of using the Hubitat Maker API to keep it all to one board but may try the 2 board approach at some point.

I wish HE could have the ESPHome Bluetooth Proxy capability that home assistant has.
I just set up BLE trackers as car presence sensors, bringing them into HE with HADB. It is very slick to turn an ESP32 into a remote Bluetooth hub. I don’t even use the BT in the raspberry pi I am running Home Assistant on.

Starting with the ‘ST_Anything_Multiples_EthernetW5x00_MEGA’ sketch and only using the PS_DS18B20_Temperature and EX_Switch capabilities with an Arduino Mega2560 and W5500 ethernet shield, I’ve tried, without success, a couple of different methods to use the temperature data locally.

I’ve tried to leverage the existing code but it seems to need more to work locally and I have been reluctant to experiment much and risk breaking your work.

I’ve also tried to merge this sketch with another I created to read the sensors and then send the data to a Nextion display. That just seems to break both sketches.

My goal is to have HubDuino functionality and also a local Nextion display where at least the temperatures can be read.

If this is even possible, do any of you have a suggestion that I could try?

@ogiewon, Will your integration work with this hardware?