Particle Photon DH and Apps

When you say RV, I assume you mean Recreational Vehicle?

Yes.

I went back and looked, and you are correct, since the partnered with NCD, they have raised the prices tremendously. When I was purchasing direct a year or two ago, the prices were no where near what they are now. I can make my own pcbs and populate them cheaper than that.

1 Like

So this code is for a photon that is connected to a LED controller? Would it be loaded as a DH? Or an APP?

Yeah. It's individually addressable LED's I have on my patio. And the Photon is the LED controller. You load it as a device. All it does is Pass a value to the photon which runs that part of the program. If you are interested I can share my photon code as well.

1 Like

Yes, I am very interested. I would like to know what board your using for the LEDs also. I bought one of the I2C boards

So the code here is the DH? which when someone places their device id and tokens into it, they can load it as a device correct?

Correct. It still requires your photon program to accept those values to do something.

Ok, I will try to load it here in a bit and see if I can get it to see it as a device. It jst looked like to me, it had "app" functions, so I wasn't sure which area to load it.

I have some drivers that can call particle functions. โ€œBasic switches button controllers etcโ€ they can also go receive particle variables via a refresh command. However Iโ€™ve found the best way to receive sensor data from the photon is to have the photon directly send sensor data to hubitat via http to the hubitat maker Api. Far less jumps and cloud complexity.

would you mind sharing those drivers?

1 Like

you got it!

heres one simple example where you give the device your particle device id access token via the input fields created as well as the particle function name you want to access. This passes a simple 1 or 0 to the function like an on off switch to for instance turn on and off a relay

// input options
preferences {
    input name: "deviceId", type: "text", title: "Device ID", required: true
    input name: "token", type: "password", title: "Access Token", required: true
    input name: "PFuncName", type: "text", title: "Particle Function Name", required: true, defaultValue: "SayMyName"
    }

// name the capabilities Attributes and author
metadata {
	definition (name: "Photon Switch", namespace: "brennonsapps", author: "bscuderi") {
        capability "Switch"

// register the custom commands
        //command "getWATT"
	}
}

// on
def on() {
	send(1)
    sendEvent(name: 'switch', value: 'on')
}
// off
def off() {
	send(0)
    sendEvent(name: 'switch', value: 'off')
}

private send(relaystate) {
    //Photon Cloud Call
	httpPost(
        uri: "https://api.particle.io/v1/devices/${deviceId}/${PFuncName}",
        body: [access_token: token, command: relaystate],  
	) {response -> log.debug (response.data)}
}

Heres one that refreshing will cause it to go get a particle variable data.. this is good for sensors. you can make a rule in rule machine for a refresh interval or I have however now for most of my particle photon sensor data now I am using a virtual device in hubitat that my photons are pushing data directly to by making an http call to the hubitat maker API.

/**
 * Particle Photon Temp Sensor
 *
 * Author: Brennon Scuderi
 *
 * 
 *
 * 
 */

preferences {
    input name: "deviceId", type: "text", title: "Device ID", required: true
    input name: "token", type: "password", title: "Access Token", required: true
    input name: "TemperatureVar", type: "text", title: "Temperature Variable", required: true, defaultValue: "InsertYourVariableHere"
    }

metadata {
    definition (name: "Particle Photon Temp Sensor", namespace: "brennonsapps", author: "Brennon Scuderi") {
        capability "Sensor"
        capability "Refresh"
        capability "Temperature Measurement"
        attribute "temperature", "number"
    }
}

// handle commands
def refresh() {
    log.debug "Executing 'refresh'"
    getTemperature()
}

private getTemperature() {
    def closure = { response ->
        log.debug "Temperature request was successful, $response.data"
        sendEvent(name: "temperature", value: response.data.result.toInteger())
    }
    httpGet("https://api.particle.io/v1/devices/${deviceId}/${TemperatureVar}?access_token=${token}", closure)
}

I have other examples that are more complex but they are basically variations of this such as my pool pump controller that works kind of like a button controller sending multiple speeds valve settings as well as multiple sensor values like rpm watts etc.. I could post that too if it helps but they all stem from these two simple ideas.

1 Like

I will set up some test photons and see what I can get setup and working. Thank you.