-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trying to get 6way wallswitch type 'ad' to work #6
Comments
@bugfinder sorry for the late reply and thank you for the pointer that the component currently has a problem with case in the hex strings. You are correct: I never had one of the devices with a non-numeric character in the identifier. The code that creates the components and registers them with homeassistant is in the folder https://github.com/gluap/pyduofern/blob/master/examples/homeassistant/custom_components/duofern/. The bottom of the file is the class that represents the entity (for instance "cover") and the top does the registration as a device with homeassistant. For instance for a duofern cover device: to_add = [DuofernShutter(device['id'], device['name'], stick, hass) for device in stick.config['devices'] if
not (device['id'].startswith('46') or device['id'].startswith('43')) and not device['id'] in hass.data[DOMAIN]['devices'].keys()]
add_devices(to_add) That line instantiates the DuofernShutter class for each ID that does fulfill the conditions and adds it to HomeAssistant using the A good start for developing for homeassistant (if a bit abstract) is the documentation on A button in homeassistant is a "binary sensor", a simple one as an example would be https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/rpi_gpio/binary_sensor.py. Even more can be learned by browsing other already-existing homeassistant component source code. For Pyduofern it was a lot of trial and error to get it right and once more when homeassistant changed the component layout. In your case see several steps to implement this: [It would be more elegant to do an asynchronous implementation where pyduofern actively triggers homeassistant as soon as the button press comes in a callback in and asynchronous api but the current way still uses the old API because pyduofern (as many other components) is not yet ported to asyncio.] |
Hi, thanks for your hints, I will try to continue on this. I was on vacation myself and have to find some time to work on this again ... but thanks to you I have some pointers now. |
I have started some work to get this running in my branch of your project
https://github.com/bugfinder/pyduofern
apparently all ids some in as lowercase on my system, maybe the items you tested were
all numerical up to now.
with my changes and a little debug code I can get the ID of the pushed button, but now
I do not have enough knowledge of home-assistant (or actually of python in general ...)
to get this working as a usable sensor in HA.
what I get with debugging is:
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster msg: 0f01071a0000010300000000040002ad23116faffe00
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster code: ad2311
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster chan: 03
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster id: 071a
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster chans: ['03']
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster msg: 0f01071a0000010400000000040002ad23116faffe00
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster code: ad2311
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster chan: 04
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster id: 071a
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster chans: ['04']
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster msg: 0f01071a0000010500000000040002ad23116faffe00
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster code: ad2311
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster chan: 05
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster id: 071a
[/usr/lib/python3.6/site-packages/pyduofern/duofern.py] DUOFERN taster chans: ['05']
so I do get the action "071a" -> "pressed" as "id" and the button number
between "01" and "06" as "chan".
how to continue from there ?
The text was updated successfully, but these errors were encountered: