how to detect power cycle on philips hue bridge? - philips-hue

How can I detect power outage on bridge? I tried using CLIP sensor daylight's lastupdated object and checked it against none but it does not help. As per meet hue description of 'lastupdated' object, it should none.
"Last time (based on /config/utc) the sensor send state data reflected in the state field. No value change is required to update the field. “none” (asof 1.x.0 null) when not initialized/no recent update has been received since the last bridge power cycle
"
But it always returns as timestamp. Can somebody suggest a way out please?
regards.

You can create a CLIPGenericStatus sensor and set it to a value that is not 0.
When the bridge restarts it will be 0 again.
You don't describe how you want to use this value (read it with by external process or trigger a rule on the bridge), but this is an indicator that you can use.

A Philips support developer recently came up with a solution on the meethue forums.
The idea here is that schedules start running when the bridge boots
and the state of a ClipGenericStatus sensor initiates its status to 0
after a reboot. This might be subject to change.
Create a ClipGenericStatus sensor.
Create a schedule that will change the status of the above ClipGenericStatus sensor to 1 every 10 to 15 seconds.
Create a rule that will do something with the lights when the above ClipGenericStatus sensor is equal to 1. The rule can for example
turn off all lights if the time is between 23.00 and 07.00. Some
downsides are:
It will also trigger when there is a reboot after disconnecting and connecting the powercord manually.
It will also trigger when there is a reboot after bridge firmware update or internal crash.
This isn't a solution for configurable startup behaviour.
Going back to last state, with saving all lightstates to a scene at a specific interval, is not recommended as it will degrade the life
expectancy of the lamps involved.
Link to original post: https://developers.meethue.com/comment/2918#comment-2918

Related

Receiving "NO CARRIER" error while tring to execute AT cmd "AT$QCRMCALL=1,1"

I am using linux 20.04 to build an image for the IMX8QXP, the image is based on kernel SUMO 4.14.98.
I am using one of the SIMCOM7600E.
I starts to dial up via NIC by using below command :
AT+CREG = 1
+CREG=1,1
return OK
AT+CGREG = 1
+CGREG=1,1
return OK
AT$QCRMCALL=1,1
return No CARRIER
I cant seem to fix the problem or figure out what is wrong. Please help me trouble shoot the problem!!
My guess would be:
The module can be registered in network, but the selected network mode may be unsuitable for data transmission (e.g. voice calls only or other). Check the preferred mode by using AT+CNMP?. The return value of 2 indicates auto.
Make sure that you have data plan available. Also remove PIN lock on the SIM card
Check if the signal quality is decent: try AT+CSQ. Its return value will be in format ,. RSSI stands for Received Signal Strength Indicator and BER for Bit Error Rate. RSSI value ranges can be in between 0 (minimum, =< -113dBm) to 31 (maximum, >= -51 dBm).
Look for more information about the operator: AT+COPS? and the network mode: AT+CPSI?
Based on the information obtained in previous steps, use an appropriate antenna or adjust its location if necessary
Don't forget about the stable power supply
If you didn't have much success with AT$QCRMCALL=1,1, try changing the USB PID of the module to 9011 (for using the modules as a RNDIS modem): AT+CUSBPIDSWITCH=9011,1,1 (the default PID is 9001)
I would flash a new firmware only as a last resort. Usually this is not necessary
Reference:
SIM7600 AT Commands manual v3.0

Get data from Hue in realtime

I'm checking the hue API and I'm wondering if I understand it correctly that the motion sensor is able to switch lights on directly via the "rules", but it is impossible to get notified via the bridge about changes?
My scenario is that I would like to detect, if there is any motion and if not to turn my TV via its rest API off.
I also read that the sensor data are just updates every 5 minutes, how can I decrease the scan interval?
If you poll the Hue bridge via API, you instantly get the motion result.
It is as simple as that:
GET http://<bridgeip>/api/<userid>/sensors/<sensor-id>
{
"state": {
"presence": true,
"lastupdated": "2018-11-01T13:43:00"
},
...
}
For checking all 1 or 2 minutes, this will work fine (while my personal way of watching TV would not assure that the motion sensor detects my presence, as the chips are too fast gone).
However, this polling is the only way to retrieve events from Hue. If there is any need to use events instantly like e.g. the Hue dimmer switches etc. for external sources: Forget it. There is no syslog, no IFITT to the outside, no HTTP triggers, or anything you could use apart from polling. Philips answers these questions in the forum in a way:
We know the demand, it is on our roadmap, we do not commit to a date
Therefore: Buying Philips Hue sensors and switches is something which binds you to the ecosystem of the Hue Bridge.
You can achieve something like it by using Apple HomeKit-automations sending shell commands to your server – even though it is somewhat of a workaround...

Contiki OS on Zolertia Z1 - Conflicting activation of phidget and battery sensors?

I build a small game controller for the Z1.
I have a process reading values from a Joystick sensor. It works fine.
Then, I added a second process, reading the value of the battery sensor every 5 minutes. But it makes the Joystick stop working: the value does not update anymore!
I found a workaround: when I have to read the value of the battery, I deactivate the phidget_sensor, activate the battery_sensor, read the value and then deactivate the battery_sensor and reactivate the phidget_sensor.
But I would like to know why I can not have both sensors activated at the same time ?
Thanks
Comes from Here.
The ADC is the "analogue to digital converter", basically is the component that provides you the voltage signal levels of an analogue sensor, so then it can later be used to translate to a meaningful value.
What happens is the battery sensor driver and the phidget driver each when starts configures the ADC on its own, thus overwriting the ADC configuration.
The expected use of both of these components is actually how you are actually using: enable, measure, then disable. This way you ensure at all times the ADC is configured the way your application expects. If you want to have this done in a single operation then I'm afraid you will need to modify probably the phidget driver and include this.
I hope this is the answer you expected, as you are asking why does this happens.

Detecting when an Apple TV 4th generation has woken from sleep

I'm working on some home automation programs and one of the things I want to be able to do is detect when my 4th generation Apple TV has woken from sleep. This will generally only ever happen when someone pressed a button on its Siri remote to wake it up.
I have a PC (connected to the same TV as the Apple TV) that has a Pulse-Eight USB-CEC adapter, so naturally the first thing I tried was using CEC to determine when the Apple TV is awake. Unfortunately it's not reliable, since monitoring the Apple TV's power status to see when it wakes up produces false positives. (I should note that I do not have "Control TVs and Receivers" enabled on the Apple TV, and can't turn it on for the particular project I'm working on because I need the Apple TV to not change the TV's input.)
I'm trying to think of some other way to do this. I'm open to any possibilities, including things like:
Making use of private APIs on the Apple TV
Running an 'always on' program in the background of the Apple TV that sends a signal when the Apple TV wakes up, if that's even possible. (I suspect that it isn't.)
Monitoring the bluetooth communication between the Siri Remote and the Apple TV, if that's possible
Somehow filtering HDMI-CEC commands so that I can turn on 'Control TVs and Receivers', allow the Apple TV's CEC commands for turning on and off the TV, and exclude commands for changing the TV's input.
Any other method, no matter how hacky or ridiculous, as long as it works!
Does anyone have any suggestions? I'm running out of things to try!
I tried to post below on apple discussion / support communities but was told i don't have the right to post this content. Maybe someone in this group can succeed in doing it:
Apple TV 4 CEC integration is great when it works, but it doesn't work all the time and not with all the various equipment out there, you can do a search across forums and you will see lots of unhappy users. I would like to use a raspberry PI to detect when my AppleTV goes to sleep and wakes up and programmatically turn my tv on or off using its RS232C or custom CEC commands.
I used a bonjour services explorer and compared every single result between sleep and on states and there are no differences whatsoever.  I would have expected Apple to welcome such automation projects and make this information readily available with a variable such as status: sleep or status: on. 
Is there a way I could tell the two states apart via the network connection?
If not, could one build a TvOS app which runs on the background and makes this information available to clients somehow?
I finally found a method that seems to work consistently. This method is incredibly hacky and not at all the sort of way I'd prefer to do this, but it's the only one I've found so far that works consistently.
I have taken an old USB webcam and affixed it to the front of my Apple TV so that its lens is directly in front of the Apply TV's front facing light. Whenever the Apple TV is asleep, I simply check for the light turning on by taking images from the camera and analyzing their average luminosity. Since the lens is right next to the light, when it turns on it'll create a huge blown out white circle in the image that's incredibly easy to detect.
As long as the Apple TV is asleep, the light turning on seems to indicate 100% of the time that it has woken up. I have yet to find a single incident of either a false positive or false negative.
Since pressing buttons on the Siri remote causes this light to blink, this also means that I can detect buttons being pressed by looking for changes in the light while the Apple TV is awake. It's not 100% accurate, since some button presses are faster than the frame rate of my crappy old USB webcam, but it works well enough.
I would vastly prefer to find a better method of doing this, like making a request over the LAN to the Apple TV where the response clearly indicates it being awake or asleep, but so far it doesn't look like that's possible.
Here I am, six and a half years later, and I've finally found a better way to get the power state of my Apple TV.
I can simply use pyatv, which has a function named power_state that returns the Apple TV's current power state.

Calculate latency for touch screen UI running on ARM controller board running Linux

I have an embedded board which has ARM controller, runs Linux as OS, which also has touch based screen. The data to the screen is taken from the Frame Buffer (/dev/fb0). Is there any way we can calculate the response time between two UI screen switching occurs when any option is selected by touch?
There are 3 latencies involved in the above scenario
1. Time taken for the touchscreen to register the finger and raise an input-event.
Usually a few milliseconds.
Enable FTRACE and log the following with timestamps
-- ISR
-- Entry of Bottom-half
-- Invoking of input_report()
2. Time taken by the app responsible for the GUI to update it.
Depending upon the app/framework, usually the most significant contributor to latency.
Add normal console logs with timestamps in the GUI app's code
-- upon receiving the input event
-- just before the command to modify the GUI
3. The time taken by the display to update.
Usually within 15-30 milliseconds
The final latency is a sum-total of the above 3 latencies.

Resources