-
-
Notifications
You must be signed in to change notification settings - Fork 223
KS220M(US) support #268
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
Comments
An integrated light sensor is used to disable the motion sensor if it's not needed: |
It also has a feature to fade the lights on or off over time. Here's what that looks like: Get current settings with it set to "Instant On" and "Instant Off": |
I'll make an attempt to add these to the code, but if someone wants to beat me to it I won't mind. |
I added the LAS and PIR sensors to the devtools script and generated the following dump: |
Based on the sysinfo, it should be detected as a Could you try and see if the controls are similar to the existing dimmer (using the PR that I just linked, Also, feel free to create a PR to add the modified devtools script as well as the fixture file to git. That can be done separately to any implementation PRs. |
You're right. It does turn on and off and the dimmer works. This is for the motion and light sensors. Is there any interest in figuring out the scheduler or 'away mode'? |
Okay, great! So the support for these new controls should be added to For scheduler, see #265. There is another development branch where some work has been done on that, but it's far from complete. The away mode scheduler is called |
I had some downtime and created the base structure for those two new modules in the linked PR. They are not yet exposed via @mrbetta if there is something missing from the |
So from what I understand, this library will support the ks220m now, correct? And if so would it be okay for me to update the readme to reflect that? |
@Chrisrdouglas there is currently no nice way to interact with the new features either using the CLI nor the API, so that's why I didn't close the issue yet. The device itself is supported afaik, so feel free to update the readme! |
@rytilahti I'm interested in using the motion sensor data for home automation. I planned to implement some quick hack to publish this info in HA via MQTT until the proper integration with HA is available. Can you share any example of how this API can be used? Thanks! |
@CrazyCoder is the sensor data available in the mobile app? If yes, you could do a traffic capture and use the script in devtools to find out how it can be read from the device. The comments above I used to create the implementation provide only information about how to change the settings as far as I know. |
@rytilahti Oh, I didn't realize that it may not expose the PIR status at all. I don't see anything in the app UI that would indicate that motion was detected or not detected. If it still exposes something, what would be the best way to find it? |
@CrazyCoder considering the comprehensive input from @mrbetta, I doubt the device is reporting the status. But you could record the communications (either by using a simulator, or tcpdumping from your router) and use the script located in the devtools to inspect the trace for anything interesting. |
I didn't see the PIR event in the captures I did, unfortunately. I had hoped to use the PIRs as a type of burglar alarm 'Away Mode' in HA, but they don't register directly as an event. Only thing I could think of was to monitor if the light turns on itself and register that as an alarm. |
@rytilahti and @mrbetta Appreciate your quick responses. I'll give up on further tinkering as it appears to be unsupported by the device firmware. I checked built-in Kasa app Smart Actions, and there is no way to set up any action based on this switch motion sensing. So it's not supported even via a cloud. There is a feature request from another user. Will use external motion sensors for automation and the built-in sensor as the last backup option with some long interval for turning off. Could have bought switches without PIR to save some money, but at least the other controls work. Thanks again guys for your great support and for maintaining this library. |
Sorry to hear that. Did you see anything besides the functionality that is already supported? I'm wondering if any of those values reported by edit: I just saw your most recent update, looks like there is nothing much that can be done. I suppose this issue could be closed considering the implementation is already in place? |
Yes, it looks like everything that is supported by the device is already implemented in this library. I tested with 1.0 HW switch, also have 1.8 HW version which I didn't try yet. I will open another issue if I find anything new. |
Should the mentioned PIR JSON commands be expected to work with an ES20M? When smartlife.iot.PIR enable is either 1 or 0, the switch does not react to movement.
Sorry if this post is not appropriate to this thread. |
Please create a separate issue or discussion for that, and describe what exactly is not working. |
Uh oh!
There was an error while loading. Please reload this page.
It'd be great if Home Assistant could be used to manage the new KS220M Motion Detection Dimmer. I set up a man in the middle proxy and captured the following JSON commands being sent from the KASA app to the switch and changed various motion sensor settings. If someone better with Python wanted to integrate these, that'd be great.
Get the current PIR config:
Sent: {"smartlife.iot.PIR":{"get_config":{}}}
Received: {"smartlife.iot.PIR":{"get_config":{"enable":0,"version":"1.0","trigger_index":2,"cold_time":60000,"min_adc":0,"max_adc":4095,"array":[80,50,20,0],"err_code":0}}}
Disable the PIR: {"smartlife.iot.PIR":{"set_enable":{"enable":0}}}
Enable the PIR: {"smartlife.iot.PIR":{"set_enable":{"enable":1}}}
Set the PIR to far range detection: {"smartlife.iot.PIR":{"set_trigger_sens":{"index":0}}}
Mid Range: {"smartlife.iot.PIR":{"set_trigger_sens":{"index":1}}}
Near Range: {"smartlife.iot.PIR":{"set_trigger_sens":{"index":2}}}
"Custom" range of 20 ft: {"smartlife.iot.PIR":{"set_trigger_sens":{"index":3,"value":61}}} (Uses decimeters?)
I'll add more objects as I find them.
The text was updated successfully, but these errors were encountered: