BSS Blu 800

Hello everyone,
I would like to thank @thebearmay for helping me so far and @tomw who has been teaching and helping me get to know the Groovy language. I have made a driver for Blu BSS 800. I can control my BSS Blu 800. But I can't make feedback yet, can anyone help me in making feedback?

This is my code:

metadata
{
    definition(name: "Blu 800 Driver", namespace: "Donny", author: "Donny")
    {
        
        command "openPort"
        command "closePort"
        command "test"
    }
}

preferences
{
    section
    {
        input name: "ipAddress", type: "string", title: "IP address", required: true, defaultValue: "192.168.1.43"
        input name: "portNum", type: "number", title: "port number", defaultValue: 1023
        input name: "logEnable", type: "bool", title: "Enable debug logging", defaultValue: true
    }
}

def logDebug(msg)
{
    if(logEnable)
    {
        log.debug(msg)
    }
}

def openPort()
{
    if(ipAddress != null && portNum != null)
    interfaces.rawSocket.connect((String) ipAddress, (int) portNum, 'byteInterface':true)
    log.debug "Opening connection"
    sendEvent(name: "status", value: "Connected")
}

def closePort()
{
    interfaces.rawSocket.close()
    log.debug "Closing connection"
    sendEvent(name: "status", value: "Disconnected")
}

def test()
{
    def msgH = [0x02, 0x8C, 0x00, 0x00, 0x00, 0x01, 0x8C, 0x03] as byte[]
    interfaces.rawSocket.sendMessage(msgH.toString())
    sendEvent(name: "preset", value: "preset 1")
    log.debug "Sending msg = ${msgH}"
}

def parse(String message)
{
    logDebug("parse: ${message}")
}

Thank you

Donny

1 Like

Look at the attributes section of this:

https://docs.hubitat.com/index.php?title=Device_Definition

You may also want to bookmark
https://docs.hubitat.com/index.php?title=Raw_Socket_Interface

1 Like