Open jlgandy2 opened 10 months ago
when the time comes i hope it will be as simple as find and replace all. kinda irritating this is happening yet again.
I tried a simple find/replace but my code editor (Visual Studio Code) flagged the python syntax as incorrect and I don't know python.
I know @kevinvincent flagged this integration as no longer supported, but perhaps he could help us out/point us in the right direction? It's amazing that this code is still in use considering the effort required to keep the sensors in play - which in my case means aggressively monitoring battery life.
@tggman I believe I was able to get this error to go away. Try replacing your binary_sensor.py file with the attached. I changed lines 23, 25, and 90. I know very little about python, I just looked at another integration I had with the same file and tried to understand how it was done there. binary_sensor.zip
Line 23: previous: from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity, DEVICE_CLASS_MOTION, DEVICE_CLASS_DOOR updated: from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity, BinarySensorDeviceClass
Line 25: previous: from homeassistant.components.binary_sensor import BinarySensorDevice as BinarySensorEntity, PLATFORM_SCHEMA, DEVICE_CLASS_MOTION, DEVICE_CLASS_DOOR updated: from homeassistant.components.binary_sensor import BinarySensorDevice as BinarySensorEntity, PLATFORM_SCHEMA, BinarySensorDeviceClass
Line 90: previous: ATTR_DEVICE_CLASS: DEVICE_CLASS_MOTION if sensor_type == "motion" else DEVICE_CLASS_DOOR , updated: ATTR_DEVICE_CLASS: BinarySensorDeviceClass.MOTION if sensor_type == "motion" else BinarySensorDeviceClass.DOOR ,
Thanks so much @jcauble! Really appreciate your detailed help and patch. Your fixes eliminated 2 out of the 3 errors in the log and WyseSense seems to be functioning as expected. Awesome. Thanks again.
I followed your logic in an attempt to fix the DEVICE_CLASS_TIMESTAMP error but had to revert those changes back when I received all sorts of errors in the log. Have you had any luck fixing this error?
Here are the changes I tried / made to binary_sensor.py which resulted in those log errors and which I reverted back:
Any additional help you can provide would be greatly appreciated.
@tggman I’m not seeing that error, where do you see it? I’m running HA 2024.10.1. I saw the errors for door and motion in my home assistant logs, but I only noticed them because I was having an unrelated problem with Wyzesense.
I too am running HAC 2024.10.1
The error: DEVICE_CLASS_TIMESTAMP was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorDeviceClass.TIMESTAMP instead, please report it to the author of the 'wyzesense' custom integration
... is under Settings/System/Logs - just like the other 2. Your error msg might be burried/reported in the same block with similar errors - like for example, the nest_protect error in the following:
Logger: homeassistant.const Source: helpers/deprecation.py:197 First occurred: 9:37:15 AM (2 occurrences) Last logged: 9:37:33 AM
DEVICE_CLASS_TIMESTAMP was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorDeviceClass.TIMESTAMP instead, please report it to the author of the 'wyzesense' custom integration TEMP_CELSIUS was used from nest_protect, this is a deprecated constant which will be removed in HA Core 2025.1. Use UnitOfTemperature.CELSIUS instead, please report it to the author of the 'nest_protect' custom integration
I figured out the fix. Here are the changes I made:
At Line 17:
Add: from homeassistant.components.sensor import SensorDeviceClass
At line 20:
Replace: ATTR_STATE, ATTR_DEVICE_CLASS, DEVICE_CLASS_TIMESTAMP
With: ATTR_STATE, ATTR_DEVICE_CLASS
At Line 91:
Replace: DEVICE_CLASS_TIMESTAMP: event.Timestamp.isoformat(),
With: SensorDeviceClass.TIMESTAMP: event.Timestamp.isoformat(),
Here's the revised file: binary_sensor.zip
Hey this is great! I applied the above patch, but I'm still having problems with my wyze contact sensors (v2) not reporting back to HA. They seem to have stopped working on 9/25 which would have been the update to 2024.9.3. I am currently running 2024.10.1. I tired replacing the battery in one door sensor, but still no change.
I see you are running 2024.10.1. Assuming your sensors are working, is there another fix you implemented as well?
You might try unplugging the usb dongle, plugging it back in, and restarting home assistant. I’ve had this happen numerous times and this fixes it.
You might try unplugging the usb dongle, plugging it back in, and restarting home assistant. I’ve had this happen numerous times and this fixes it.
Beautiful. This was it. Thanks!
I am seeing in the logs the following: DEVICE_CLASS_TIMESTAMP was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorDeviceClass.TIMESTAMP instead, please report it to the author of the 'wyzesense' custom integration DEVICE_CLASS_MOTION was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use BinarySensorDeviceClass.MOTION instead, please report it to the author of the 'wyzesense' custom integration DEVICE_CLASS_DOOR was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use BinarySensorDeviceClass.DOOR instead, please report it to the author of the 'wyzesense' custom integration
Is this something easy to update?
I've updated the code to resolve the all of the errors. Feel free to try out my newer code. https://github.com/stewjoel/ha-wyzesense/
i applied stewjoel's edits to binary_sensor.py in my own fork. so far so good. the commits did overwrite the previous fix i applied from issue #189 so we'll see how that goes.
# From https://github.com/kevinvincent/ha-wyzesense/issues/189
try:
entities[event.MAC].schedule_update_ha_state()
except (AttributeError, AssertionError):
_LOGGER.debug("wyze Sensor not yet ready for update")
replaced with:
hass.add_job(entities[event.MAC].async_write_ha_state)
async def update_storage(hass, mac):
storage = await getStorage(hass)
if mac not in storage:
storage.append(mac)
await setStorage(hass, storage)
I am seeing in the logs the following: DEVICE_CLASS_TIMESTAMP was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use SensorDeviceClass.TIMESTAMP instead, please report it to the author of the 'wyzesense' custom integration DEVICE_CLASS_MOTION was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use BinarySensorDeviceClass.MOTION instead, please report it to the author of the 'wyzesense' custom integration DEVICE_CLASS_DOOR was used from wyzesense, this is a deprecated constant which will be removed in HA Core 2025.1. Use BinarySensorDeviceClass.DOOR instead, please report it to the author of the 'wyzesense' custom integration
Is this something easy to update?