fuatakgun / eufy_security

Home Assistant integration to manage Eufy Security devices as cameras, home base stations, doorbells, motion and contact sensors.
877 stars 73 forks source link

CARD management - Creation of further ATTRIBUTES - Insertion of sensors in binary_sensor.py #95

Closed SmartM-ui closed 2 years ago

SmartM-ui commented 2 years ago

Hi, I created a card with the ability to control the cam in 4 directions, with motion / audio alert sensors, the various security modes, the refresh for manual synchronization and the ability to manage settings as per the official Eufy App, which are synchronized bidirectionally.

At the moment, the status LED and Automatic Night Vision are not synchronized bi-directionally. It is possible to send the command from Home Assistant (and see it on the official App), but it is not possible to see the real status on Home Assistant when the command is sent from the official Eufy App. If you have any advice, they are welcome!

@fuatakgun I proceeded to create three other binary sensors in the binary_sensor.py file, you can integrate them in the addon as you did for the ones I had previously inserted:

        ("motion_detection_enabled", "Motion Detection", "state.motionDetection", None, DEVICE_CLASS_MOTION),
        ("sound_detection_enabled", "Sound Detection", "state.soundDetection", "mdi: account-voice", None),
        ("pet_detection_enabled", "Pet Detection", "state.petDetection", "mdi: dog", None),

Also, could you create the missing attributes for Person Detection and All Other Detection? I couldn't find them and I'd like to finish the card and make it complete.

@bropat The Pet Detection sensor attribute does not seem to work as it does not send the command to enable or disable such detection. I tried in the following ways:

              - service: eufy_security.send_message
                date:
                  message: | -
                    {
                      "messageId": "petDetection",
                      "command": "device.set_property",
                      "serialNumber": "T8410Pxxx",
                      "name": "petDetection",
                      "value": true (or false)
                    }
              - service: eufy_security.send_message
                date:
                  message: | -
                    {
                      "messageId": "message_id_do_not_add_value_here",
                      "command": "device.set_pet_detection",
                      "serialNumber": "T8410Pxxx",
                      "value": true (or false)

Could you kindly tell me what is the right command to activate animal detection? Thanks

@DivanX10 did you manage to create the slider to change the speaker volume? In case you could share the code so I put it on the card? Thanks

When the card is tested and fully functional, if anyone cares, I'll be happy to share it

Schermata 2021-10-26 alle 16 47 18

Just for info, the card provides an image when the cam is off, another when the cam is starting up and finally the stream in real time with webrtc.

DivanX10 commented 2 years ago

did you manage to create the slider to change the speaker volume? In case you could share the code so I put it on the card? Thanks No, it still doesn't work. The service does not want to start and writes about an error if I specify a variable, only if I specify a specific number. I do not know how else to make it work Writes an error that the service could not be called hijack_security.send_message. Unknown error

service: eufy_security.send_message
data:
  message: |-
    {
      "messageId": "cmdspeakerVolume", 
      "command": "device.set_property",
      "serialNumber": "T8410XXX",
      "name": "speakerVolume",
      "value": {{ states("input_number.eufy_camera_hall_speaker_volume")|round }}
    }
kitprice commented 2 years ago

@SmartM-ui If you are trying to set the motion detection for only pets, you can use the following:

service: eufy_security.send_message
data:
  message: |-
    {
      "messageId" : "cmdMotionDetectionType.petDetection",
      "command" : "device.set_property",  
      "serialNumber" : "XXXX", 
      "name" : "motionDetectionType",  
      "value" : 2
    }

The value is bitwise, with the following values :

1 = Person detection 2 = Pet detection 4 = All other motion detection

So, you can always combine them to get the desired results. For instance, 7 is a combination of all the motion sensors; 3 is just person and pet. Note that you cannot set to 0, at least one detection type must be selected.

The "petDetection" command is only for notifications.

SmartM-ui commented 2 years ago

@SmartM-ui If you are trying to set the motion detection for only pets, you can use the following:

service: eufy_security.send_message
date:
  message: |-
  {
    "messageId" : "cmdMotionDetectionType.petDetection",
    "command" : "device.set_property",  
    "serialNumber" : "XXXX", 
    "name" : "motionDetectionType",  
    "value" : 2
  }

The value is bitwise, with the following values :

1 = Person detection 2 = Pet detection 4 = All other motion detection

So, you can always combine them to get the desired results. For instance, 7 is a combination of all the motion sensors; 3 is just person and pet. Note that you cannot set to 0, at least one detection type must be selected.

The "petDetection" command is only for notifications.

Thanks! I try now :-)

SmartM-ui commented 2 years ago

@fuatakgun sorry, I closed by mistake!

SmartM-ui commented 2 years ago

Hi @kitprice , I'm trying to send the command from developer templates, but the motionDetectionType attribute doesn't change.

If I change the type of object to be detected by the eufy app, I actually display the motionDetectionType attribute with the number as you described

Does the command you posted work for you?

kitprice commented 2 years ago

@SmartM-ui That is cut-and-pasted from my developer template, which came directly from my script. I only changed the serialNumber. Be sure to refresh the app after a change or even restart the app. It will not update in real-time or even based on a poll, as far as I can tell.

I've only tested this successfully with the lower resolution indoor cameras (C22/P22). I think this should work on the 2k indoor cameras (C24/P24), as well. I also have outdoor floodlight (1024) and eufyCam 2C and this function does not appear to support this capability change. Also, neither supports pet detection.

SmartM-ui commented 2 years ago

@kitprice

OK, I found, it was badly indented.

So it works perfectly:

service: eufy_security.send_message
data:
   message: | -
     {
       "messageId": "cmdMotionDetectionType.petDetection",
       "command": "device.set_property",
       "serialNumber": "XXX",
       "name": "motionDetectionType",
       "value": 2
     }

THANK YOU!

kitprice commented 2 years ago

Sorry! That was my fault. I originally only pasted the message section and added the whole service later... and I did some bad editing. I updated my original post with correctly formatted yaml.

fuatakgun commented 2 years ago

I have added 3 specific more sensor you had asked in the main issue. if you need more please specify them. they will be available in next version.

SmartM-ui commented 2 years ago

I have added 3 specific more sensor you had asked in the main issue. if you need more please specify them. they will be available in next version.

Hi @fuatakgun thank you for accommodating my requests! I went ahead with the Card, if possible and if you like to share, could you also insert this sensor in sensor.py please?

("speakervolume", "speakerVolume", "state.speakerVolume", PERCENTAGE, None, None),
("motionDetectiontype", "motionDetectionType", "state.motionDetectionType", None, None, None),

In binary sensor, compared to what is reported in the first post, there are the following sensors (I eliminated the Pet Detection sensor as it is not recognized by the eufy app and I added the LED status)

         ("motion_detection_enabled", "Motion Detection", "state.motionDetection", None, DEVICE_CLASS_MOTION),
         ("sound_detection_enabled", "Sound Detection", "state.soundDetection", "mdi: account-voice", None),
         ("led_status_enabled", "Led Status", "state.ledStatus", "mdi: led-on", None),

This is the progress of the card:

Schermata 2021-11-10 alle 12 35 39
SmartM-ui commented 2 years ago

I have added 3 specific more sensor you had asked in the main issue. if you need more please specify them. they will be available in next version.

Hi @fuatakgun , I made the update proposed yesterday for your HACS integration, but there are no new sensors, (not even the binary sensors of the first post)

Just for information, do you think you put them in for everyone or do you prefer me to package the sensors just for me (for the card)? The sensors I added are:

binary_sensor.py

        ("motion_detection_enabled", "Motion Detection", "state.motionDetection", None, DEVICE_CLASS_MOTION),
        ("sound_detection_enabled", "Sound Detection", "state.soundDetection", "mdi: account-voice", None),
        ("led_status_enabled", "Led Status", "state.ledStatus", "mdi: led-on", None),

sensor.py:

        ("speakervolume", "speakerVolume", "state.speakerVolume", PERCENTAGE, None, None),
        ("motionDetectiontype", "motionDetectionType", "state.motionDetectionType", None, None, None),

Thanks

fuatakgun commented 2 years ago

please get latest version: https://github.com/fuatakgun/eufy_security/issues/59#issuecomment-968352909

SmartM-ui commented 2 years ago

please get latest version: #59 (comment)

Hi @fuatakgun , i just updated Eufy HACS (3ddbb3e) and noticed these two sensors are missing in sensor.py:

("speakervolume", "speakerVolume", "state.speakerVolume", PERCENTAGE, None, None),
("motionDetectiontype", "motionDetectionType", "state.motionDetectionType", None, None, None),

and the ledStatus sensor in binary_sensor.py (for new version addon-hacs:)

("status_led_enabled", "Status Led", "state.statusLed", "mdi: led-on", None),

Could you add them please? If it's not possible, I put them in my packages so I don't have to manually put them back on every update.

Thanks

fuatakgun commented 2 years ago

added

SmartM-ui commented 2 years ago

added

Hi, thanks, sensors are missing in sensor.py:

("speakervolume", "speakerVolume", "state.speakerVolume", PERCENTAGE, None, None),
("motionDetectiontype", "motionDetectionType", "state.motionDetectionType", None, None, None),