Is it possible to detect if Philips Hue light is unplugged? - philips-hue

I need to somehow record, when the light is unplugged. The bridge seems to return the 'last recorded' value. If the light was 'on' before unplugging, it still returns 'on', even after it is unplugged.
Absolutely nothing seems to be changing in the output, if the light is unplugged. Any ideas?

Yes, you can check the light's state variable named "reachable". This is set to false when the bridge fails to connect to the light, such as when it is unplugged or when a physical switch cuts the power to the light. As you noted, the other attributes just tell you what the various values were the LAST time the bridge was able to reach the light.
{
"state": {
"on": true,
...
"reachable": false
},
...
}
Additionally, you can use a rule or sensor to monitor the value of that attribute and take some action when it switches from true to false or vice versa.

Related

Availability Test in Application Insights atuomatically disables

We have a very simple Application Insights Availability Test (That hits an HTTPS URL across 4 US regions) (basically it hits our App Service).
What we have observed it this Availability test automatically stops (not a fixed scheduled) but it abruptly stops and then what we have to do is go back to Availability test Edit the Test and Save it again so that it restarts.
This is really weird as we have checked the Activity log also and nothing is reported in it about someone stopping the Test, etc.
Any help on how this can be tackled? As abrupt stoppage of Availability Test (Tests getting grayed out) is really serious as we wont know if there is any outage untill someone reports back on the service.
The behavior was caused by two issues and should not be wide spread:
Issue with ARM Template
A possible bug on App Insights Availability configs
This is interesting corner case, caused by a bug in ARM template and discrepancy between how our Front and Back ends handled it. In provided ARM template there were two tags defined:
"tag": "[concat('hidden-link:/subscriptions/',subscription().id,'/resourceGroups/',resourceGroup().name,'/providers/microsoft.insights/components/',parameters('appInsightsName'))]",
"linkToAiResource": "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]",
"tags": {
"[variables('tag')]": "Resource",
"[variables('linkToAiResource')]": "Resource"
},
These two tags instantiated into this:
"hidden-link:/subscriptions//subscriptions/xxx/resourceGroups/yyy/providers/microsoft.insights/components/zzz": "Resource",
"hidden-link:/subscriptions/xxx/resourceGroups/yyy/providers/microsoft.insights/components/zzz": "Resource"
Note, we have duplicated “/subscriptions/” in the first tag. So, two issues:
There were two such links in the first place
The first of them is invalid (I guess subscription().id already includes “/subscriptions/” part).
The fix should be straightforward – just leave the second tag (we validated that it starts working).
Now, the bug on our side is that the logic of how this case is handled differs between Front and Back ends:
Front end successfully finds a valid “Resource” hidden-link (ignoring invalid one)
Back end (I guess) uses the first one, finds that it points to (apparently) deleted resource and marks this test as deleted as well. This results in stopping this test
We will adjust the logic. Either will start failing at Front End and will change Back End to use the same logic (fix will be rolled some time in Jan).

How to create dependencies in statechart?

Example StateChart
I've got a system, that is depending on another system.
I want to display this in a statechart.
System 1: microwave_state with two states: On and Off
When microwave_button is pressed AND system 2 current state is true, then ON
else Off
System 2: electricity_state with two states: True and False.
When electricity bill is payed then True else False
How can I display that dependency in a statachart?
You would do it like this:
The "current from system2" is just a guard for the transition. From my POV system2 is not a state machine, but a simple boolean value.

Unreal engine: How to get FHitResult.FaceIndex?

When I do
PlayerController->GetHitResultUnderCursor(ECollisionChannel::ECC_WorldDynamic, false, TraceResult);
TraceResult.FaceIndex is always -1.
Here #OriCohen says that I have to "use a triangle mesh for the query". Do I have to use GetHitResultUnderCursorForObjects() with "triangle mesh" for the object type? Then how should I do it (EObjectTypeQuery is very obscure to me)?
Here is the question on UE4 answerhub.
To obtain a valid FaceIndex you need to make sure bReturnFaceIndex and bTraceComplex are set to true in your FCollisionQueryParams.

When can we get access to nest autoaway status?

Let me stress that I am not a programmer but I like messing around with things. I've been using #ifttt and #nest for years and recently started using #smartthings to do cool things in my house.
I wanted to power off devices such as my lights and water heater based on leaving my house. Rather than having this depend on one device such as a phone or keyfoob, I wanted to use the nest "auto-away" feature.
Auto-away doesn't appear to be exposed to #ifttt or #smartthings. I've asked #nestsupport and they told me to come here :-o.
Does anyone from nest developer team know when developers and other products will be able to consume this from he nest device? Its a real shame that after several years this isn't exposed yet. Not only that but it could be an additional selling point to integrate and turn on/off items in your house.
Thank
I'm not from the Nest developer team, but I've played around with the Nest API in the past, and use it to plot my energy usage.
The 'auto away' information is already accessible in the API, and looks to be used in a number of IFTTT recipes:
https://ifttt.com/recipes/search?q=auto+away&ac=false
Within the (JSON) data received back in the API, the 'auto away' status is accessible via;
shared->{serial_number}->auto_away
This is set as a boolean (0 or 1).
If you like messing around with code, and know any PHP, then this PHP class for the Nest API is very useful at grabbing all information etc;
https://github.com/gboudreau/nest-api
Auto-Away is and always has been readable https://developer.nest.com/documentation/cloud/api-overview#away
There are a few ways you could go about doing this, but if you're writing up a SmartApp just for your own uses, I'd suggest piggybacking off of one of the existing device types for the Nest on SmartThings. As a quick example, I'll use the one that I use:
https://github.com/bmmiller/device-type.nest/blob/master/nest.devicetype.groovy
After line 96, this is to expose the status to any SmartApp you may write:
attribute "temperatureUnit", "string"
attribute "humiditySetpoint", "number"
attribute "autoAwayStatus", "number" // New Line
Now, you'll want to take care of getting the data in the existing poll() method, currently starting at line 459.
After line 480, to update the attribute
sendEvent(name: 'humidity', value: humidity)
sendEvent(name: 'humiditySetpoint', value: humiditySetpoint, unit: Humidity)
sendEvent(name: 'thermostatFanMode', value: fanMode)
sendEvent(name: 'thermostatMode', value: temperatureType)
sendEvent(name: 'autoAwayStatus', value: data.shared.auto_away) // New Line
This will expose a numerical value for the auto_away status.
-1 = Auto Away Not Enabled
0 = Auto Away Off
1 = Auto Away On
Then, in your SmartApp you write, where you include an input of type thermostat like this:
section("Choose thermostat... ") {
input "thermostat", "capability.thermostat"
}
You will be able to access the Auto Away status by referring to
thermostat.autoAwayStatus
From anywhere in your code where you can do something like
if (thermostat.autoAwayStatus == 1) {
// Turn off everything
}

Nest API: when is Thermostat 'heating' or 'cooling'?

The Nest Thermostat device will display on-screen if it's 'cooling' or 'heating'. How do I get this state through the Nest API?
The hvac_mode property seems to simply show what the user's Thermostat is capable of controlling and doesn't change when either cooling or heating occurs.
For now, I'm using a simple but not flawless logic:
if (can_cool && target_temperature < ambient_temperature) --> isCooling
if (can_heat && target_temperature > ambient_temperature) --> isHeating
else --> isDoingNothing
By not flawless, I mean that I've encountered situations where this logic is incorrect. For example, in a given situation where the ambient_temperature is 20 Celsius and the target_temperature is 21 Celsius with can_heat set to true, my UI will say the Thermostat is heating, while it actually isn't.
This is probably because target and ambient temperatures are too close, but I don't know what the threshold is.
Is there another or better way to figure out heating and cooling states?
As of May 2015, the Nest API now officially reports the hvac_state property. The value will be one of either 'heating','cooling' or 'off'.
New fields in the data model:
hvac_state.
You'll use hvac_state to learn if the home HVAC system is actively heating, cooling or is off.
Looking at the API, they don't provide any way of identifying if the thermostat is actually heating. The closest you can get to identify is what you currently have written.
If the device itself is capable of displaying it's heating or cooling, they must have different code or different methods (such as internal electronics) for identifying that.
Sadly you're correct - the API does not reveal this information.
In my application I've implemented the same logic as you, and have noticed the same issue around edge cases. I suspect that there may be a time-element to it when the ambient temperature is just outside of the target temperature by only a degree or less.
You need to track the status of Heat On/off in order to calculate properly. I monitor the NEST at 1 hz and store the last state (On or Off) as a variable. once you have this info you can use the following logic and it will be accurate:
if lastStatus.Contains("Off"))
{
if (temp_current < temp_setpoint)
status = "Heat On";
else
status = "Heat Off";
}
else if (lastStatus.Contains("On"))
{
if (temp_current > temp_setpoint)
status = "Heat Off";
else
status = "Heat On";
}
// Do the work....
lastStatus=status;
Note: temp_current and temp_setpoint are returned from the REST http post.
Good Luck!

Resources