Page 1 of 1

Aqara Presence Sensor FP2 gives error

PostPosted: Sun Mar 03, 2024 9:29 am
by CliveS
I have an Aqara FP2 Presence sensor which I used to import into indigo from HomeKit as a variable but since I now have Home Assistant running natively on my 2014
MacBook I decided to try Home Assistant Agent.

This works great as the Presence and Lux values are correct but the GUI state shows ‘off’ and I get an error each time the lux changes

Code: Select all
  Error                           device "Aqara FP2 Lux Sensor Via Home Assistant" state key sensorValue not defined (ignoring update request)

I have modified the code to ignore the error but I would need to change it every time you update the plugin.

The diagnostics from HA for this device shows.



And the Indigo Lux and Presence device details
Code: Select all
  Script                          address : binary_sensor.presence_sensor_fp2_689f_presence_sensor_1
allowOnStateChange : False
allowSensorValueChange : False
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : HAbinarySensorType
displayStateId : onOffState
displayStateImageSel : MotionSensorTripped
displayStateValRaw : True
displayStateValUi : on
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 603788583
globalProps : MetaProps : (dict)
     no.homeassistant.plugin : (dict)
          SupportsOnState : true (bool)
          SupportsSensorValue : false (bool)
          SupportsStatusRequest : false (bool)
          address : binary_sensor.presence_sensor_fp2_689f_presence_sensor_1 (string)
          states_list : (list)
               Item : device_class (string)
               Item : friendly_name (string)
id : 408117572
lastChanged : 2024-03-03 15:00:11
lastSuccessfulComm : 2024-03-03 15:00:11
model : Home Assistant Binary Sensor
name : Aqara FP2 Presence Sensor Via Home Assistant
onState : True
ownerProps : no.homeassistant.plugin : (dict)
     SupportsOnState : true (bool)
     SupportsSensorValue : false (bool)
     SupportsStatusRequest : false (bool)
     address : binary_sensor.presence_sensor_fp2_689f_presence_sensor_1 (string)
     states_list : (list)
          Item : device_class (string)
          Item : friendly_name (string)
pluginId : no.homeassistant.plugin
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
sensorValue : None
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)
     actual_state : on (string)
     device_class : occupancy (string)
     friendly_name : Living Room FP2 Presence (string)
     lastUpdated : 2024-03-03T15:00:11.380432+00:00 (string)
     onOffState : on (on/off bool)
subModel :
subType :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsOnState : True
supportsSensorValue : False
supportsStatusRequest : False
version : None

3 Mar 2024 at 15:13:38
   Script                          address : sensor.presence_sensor_fp2_689f_light_sensor_light_level
allowOnStateChange : False
allowSensorValueChange : False
batteryLevel : None
buttonGroupCount : 0
configured : True
description :
deviceTypeId : HAsensor
displayStateId : onOffState
displayStateImageSel : NoImage
displayStateValRaw : False
displayStateValUi : off
enabled : True
energyAccumBaseTime : None
energyAccumTimeDelta : None
energyAccumTotal : None
energyCurLevel : None
errorState :
folderId : 603788583
globalProps : MetaProps : (dict)
     no.homeassistant.plugin : (dict)
          SupportsOnState : true (bool)
          SupportsSensorValue : false (bool)
          SupportsStatusRequest : false (bool)
          address : sensor.presence_sensor_fp2_689f_light_sensor_light_level (string)
          states_list : (list)
               Item : state_class (string)
               Item : unit_of_measurement (string)
               Item : device_class (string)
               Item : friendly_name (string)
id : 70681190
lastChanged : 2024-03-03 15:07:49
lastSuccessfulComm : 2024-03-03 15:07:49
model : Home Assistant Value Sensor
name : Aqara FP2 Lux Sensor Via Home Assistant
onState : False
ownerProps : no.homeassistant.plugin : (dict)
     SupportsOnState : true (bool)
     SupportsSensorValue : false (bool)
     SupportsStatusRequest : false (bool)
     address : sensor.presence_sensor_fp2_689f_light_sensor_light_level (string)
     states_list : (list)
          Item : state_class (string)
          Item : unit_of_measurement (string)
          Item : device_class (string)
          Item : friendly_name (string)
pluginId : no.homeassistant.plugin
pluginProps : emptyDict : (dict)
protocol : Plugin
remoteDisplay : True
sensorValue : None
sharedProps : com.indigodomo.indigoserver : (dict)
states : States : (dict)
     actual_state : 29 (string)
     device_class : illuminance (string)
     friendly_name : Living Room FP2 Lux (string)
     lastUpdated : 2024-03-03T15:07:49.442662+00:00 (string)
     onOffState : off (on/off bool)
     state_class : measurement (string)
     unit_of_measurement : lx (string)
subModel :
subType :
supportsAllLightsOnOff : False
supportsAllOff : False
supportsOnState : True
supportsSensorValue : False
supportsStatusRequest : False
version : None

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Tue Mar 05, 2024 11:26 am
by anyone
Try configuring the light sensor as a Home Assistant Value Sensor.

I've set mine up this way. The GUI accurately displays the lux value, and no errors are logged when the lux changes.

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Tue Mar 05, 2024 12:48 pm
by CliveS
anyone wrote:
Try configuring the light sensor as a Home Assistant Value Sensor.

I've set mine up this way. The GUI accurately displays the lux value, and no errors are logged when the lux changes.


I have set it up like this


Screenshot 2024-03-05 at 18.37.48.png
Screenshot 2024-03-05 at 18.37.48.png (219.17 KiB) Viewed 656 times


but still get the error unless I modify the plugin to ignore 'illumination'

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Tue Mar 05, 2024 5:51 pm
by anyone
Try deleting the device named "HA Living Room FP2 Lux Sensor" and then recreate it as a "Home Assistant Value Sensor".

I believe I have replicated the same errors you're encountering by not creating the Light sensor directly. Instead, I modified an existing Binary Sensor, changing it to a Value Sensor, and updated the Entity to the light sensor. That lead to the issue.

Code: Select all
 Error                           device "Carriage House LIght Sensor Testing" state key sensorValue not defined (ignoring update request)

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Tue Mar 05, 2024 7:19 pm
by FlyingDiver
I've run into this before. Changing the type of an existing device doesn't always work right. Probably something I'm doing wrong in my code.

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Wed Mar 06, 2024 9:32 am
by CliveS
anyone wrote:
Try deleting the device named "HA Living Room FP2 Lux Sensor" and then recreate it as a "Home Assistant Value Sensor".

I believe I have replicated the same errors you're encountering by not creating the Light sensor directly. Instead, I modified an existing Binary Sensor, changing it to a Value Sensor, and updated the Entity to the light sensor. That lead to the issue.

Thank you for digging into this so much, that was the answer and it is now showing '9lx' instead of 'off',
I suppose I was making a Frankenstein device, with the 'states' being correct but the GUI State was getting the current occupancy of off or on.
So much better having a 'device' compared to the shortcuts method giving 'variables'.
Until (if) Aqara update it to Matter I have now used Glenn's HK plugin to get the values back into the Home app, long way round but works perfectly.

Once again, Thanks

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Wed Mar 06, 2024 9:40 am
by CliveS
FlyingDiver wrote:
I've run into this before. Changing the type of an existing device doesn't always work right. Probably something I'm doing wrong in my code.


Joe, the code works fine, it's definitely me not thinking it through is the problem.
And as I write this the lights turn on as the light level gets below the threshold thanks to the plugin!
Thanks.

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Fri Mar 08, 2024 5:55 pm
by norcoscia
Just wanted to say thanks for posting about this - I installed the Aqara FP2 Presence sensor and it works like magic, so much better than anything else I have tried.

It solved a 7 year problem I had with the lights turning off in my laundry room if I was standing at the sink washing something - every other sensor would not detect with out any motion — this one works perfect and the zone control is like something from the future.

In case anyone else wants to try one, the process is

1. Install the Aqara app
2. Power up the Aqara FP2 Presence sensor and add it to the Aqara application
3. Find the Aqara FP2 Presence sensor in your apple home application
4. Delete Aqara FP2 Presence sensor from the apple home application (this makes it visible for Home Assistant to see)
5. Verify it is in your Home Assistant
6. Add it to Home Assistant Agent (note — add the Aqara Presence sensor and luminance sensor as separate devices in Indigo)

Let me know if I missed anything…

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Fri Mar 15, 2024 1:21 pm
by anyone
norcoscia wrote:
Let me know if I missed anything…


Here's a concise guide on setting up the Aqara FP2 Presence Sensor with Home Assistant.
https://www.derekseaman.com/2023/04/home-assistant-setting-up-the-aqara-fp2-presence-sensor.html

Also check out FlyingDiver's Occupatum Plugin, which integrates well with FP2 sensors allowing you to add delays for occupancy/presence based triggers.

Re: Aqara Presence Sensor FP2 gives error

PostPosted: Sat Mar 16, 2024 5:01 am
by norcoscia
Thanks!!!