Hello!
A while ago I “irresponsibly” bought a Hama “smart” window/door sensor thinking that Hama (a somewhat well known brand in Germany and Austria) had an integration with Homeassistant (or at least via HACS).
As I painfully found out, it didn’t have any integration with Homeassistant.
This took me a while to figure out how to get it working, so I thought I should share it with the community.
So I looked through some forum posts to find out, that apparently the Hama devices are pretty much tuya devices.
It is therefor possible to pair the sensor with the “tuya smart” app like you would with the official Hama app.
You can pretty clearly see, that in the app, if you touch the two pieces of the sensor together it “closes” the window/door and vice versa.
Seeing as there was no issue in displaying the state of the sensor in the tuya smart app I went out to connect it to Homeassistant via the official tuya integration (over the Tuya API).
For this, you have to create a cloud project in the Tuya IoT Cloud Platform and then link your tuya smart app to the project to be able to see all the devices you linked with your phone and the app.
When you got around the awful UI of the website and you could see all the devices (or just the one Sensor) that you linked through the app, you can then get the “Tuya IoT Access ID” and “Tuya IoT Access Secret” from the “Overview” Page of your Project and paste them into the integration setup window in HASS.
You will then find out, that the sensor is shown as “unsupported” in the integration and that it has no entities associated with the device.
This was the biggest Problem in all of this, since I could see in the Tuya API that it does detect that it opens and closes, but that information does not get forwarded to HASS (probably because its not a real tuya device and the integration doesn’t know what to do with that information).
The workaround for this was to add a Virtual Device in the Tuya IoT Cloud Page.
For that you have to create an “Asset” under the “Assets” tab (give it any name)
You can then go to the “Devices” tab and add a new virtual device.
There you choose which Asset you want it to be created under and what device it should be.
I chose a random light switch, since I just needed an “on” and an “off” state and nothing more.
When you add the virtual device you have to link it to the Tuya Smart app via the QR code that is displayed.
When you can see the device, you can rename it and most importantly create automations in the Tuya Smart app with it.
In the app you just need to create a new automation where, whenever the window/door sensor is closed, it turns the virtual light switch off and then another automation, for the opposite (sensor open → light switch on)
This makes it so you can now also see the virtual device in Homeassistant (when you refresh the tuya integration).
The switch of the the virtual light switch then turns off and on depending if your window/door sensor is opened or closed.
You can now create templates like
template:
- binary_sensor:
- name: "window"
state: >
{{ states("switch.guo_biao_yi_lu_kai_guan_hong_mo_wi_fi_bluetooth_le_switch_1") | bool }}
to give it a better entity name and make it a sensor instead of a switch.
There are probably better ways to get around this problem (like a local tuya integration, using tinytuya… or just buying a better sensor with an official integration)
I hope this helped the few people out there who might have made the same mistake. Maybe it can also be used on other random tuya devices that have the same problem.
This is my first post on the forum so I hope the formatting isn’t terrible and the content is somewhat helpful.