Skip to content
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

[suggestion] cleaning mode #4

Open
leonardpitzu opened this issue May 2, 2019 · 15 comments
Open

[suggestion] cleaning mode #4

leonardpitzu opened this issue May 2, 2019 · 15 comments
Labels
enhancement New feature or request

Comments

@leonardpitzu
Copy link

one thing to add is a way to control the cleaning mode: vacuum/mop and the power level associated with it. My first idea would be to add a fan mode which can be controlled but this is tricky as the user needs to remember which percent of the fan corresponds to which cleaning mode. Another idea would be to have switches for cleaning and mopping. Still you somehow need to control the power levels for vacuuming...
Mopping is tricky as it is missing from valetudo. It's an additional mode during which the vacuum moves slower.
I modified valetudo as follows:

var fanspeeds = { 38: "Quiet", 60: "Balanced", 75: "Turbo", 100: "Max", 105: "Mop" };

`function handleFanspeedButton() {
window.clearTimeout(currentRefreshTimer);

                ons.openActionSheet({
                    title: 'Select power mode',
                    cancelable: true,
                    buttons: [
                        'Quiet',
                        'Balanced',
                        'Turbo',
                        'Max',
                        'Mop',
                        {
                            label: 'Cancel',
                            icon: 'md-close'
                        }
                    ]
                }).then(function (index) {
                    var level;

                    switch (index) {
                        case 0:
                            level = 38;
                            break;
                        case 1:
                            level = 60;
                            break;
                        case 2:
                            level = 75;
                            break;
                        case 3:
                            level = 100;
                            break;
                        case 4:
                            level = 105;
                            break;
                    }

                    if (level) {
                        loadingBarHome.setAttribute("indeterminate", "indeterminate");
                        fanspeedButton.setAttribute("disabled", "disabled");
                        fn.requestWithPayload("api/fanspeed", JSON.stringify({ speed: level }), "PUT", function (err, res) {
                            if (err) {
                                fanspeedButton.removeAttribute("disabled");
                                loadingBarHome.removeAttribute("indeterminate");
                                ons.notification.toast(err, { buttonLabel: 'Dismiss', timeout: 1500 })
                            } else {
                                window.clearTimeout(currentRefreshTimer);
                                window.setTimeout(function () {
                                    updateHomePage();
                                }, 150);
                            }
                        })
                    } else {
                        window.setTimeout(function () {
                            updateHomePage();
                        }, 3000);
                    }
                });
            }`
@leonardpitzu
Copy link
Author

battery status would also be nice

@onfoot
Copy link
Owner

onfoot commented May 2, 2019

Yeah, I've been thinking how to approach the cleaning modes, especially the power, and thought that the solution using a fan accessory for both mop and non-mopping modes is not a very fortunate one.

A separate switch for mopping mode, and a fan accessory for non-mopping modes rescaled to 0-100 should do at least. But we would have to be able to detect whether the vacuum the plugin is controlling is a mopping-capable robot.

OR, maybe besides the normal/mop mode switch, provide a config setting for any two modes the user prefers, so they'd get a switch for Quiet/Max, or Balanced/Turbo, etc. Currently I'm using only one mode anyway, as when I'm not at home I don't care how quickly the vacuum will do its job.

The battery status is there in every accessory already - whether it's charging, battery level and low level state. Or maybe you're thinking of a "status accessory" for something battery-related?

@onfoot onfoot added the enhancement New feature or request label May 2, 2019
@leonardpitzu
Copy link
Author

i was thinking of a mixture...
a switch for on off
a switch (with a config flag to enable it for gen.2) for mop on/off
a fan (a multi-level switch would be nicer) for vacuum power
a sensor for displaying battery level

@onfoot
Copy link
Owner

onfoot commented May 3, 2019

Which sensor for battery level would you have in mind? Nothing existing really fits, and I don't know whether a custom accessory would show up as a sensor showing a numeric value, for example. The ones that do are I think light level (in lux), temperature (celsius or fahrenheit), and humidity (percentage). That's it, I think.

The rest are devices you can control, like doors, window coverings, fans, bulbs.

@leonardpitzu
Copy link
Author

I think of the humidity sensor as it’s percentage and fits the battery level reported by Valetudo.

@onfoot
Copy link
Owner

onfoot commented May 6, 2019

By the way, have you tried to send a pull request for Valetudo with the speed modes? They use their own values in the client for the different speeds, but their own fake backend actually does define the presets available in the official robot's interface (i.e. Quiet, Balanced, Turbo, Max, Mop). I implemented those, but when they are set, the default Valetudo interface shows undefined. :D

@leonardpitzu
Copy link
Author

pushed ;)

@onfoot
Copy link
Owner

onfoot commented May 9, 2019

In case you didn't notice, 0.1.2 is live with cleaning modes. I'm still contemplating the humidity sensor as battery indicator idea.

Is it really useful to see the battery level in the Home app directly? Would you do anything about it if it crossed a specific threshold? Do you want to set up automations with it (e.g. red lights turn on in the living room if the battery is low ;) )?

Not saying it's a terrible idea and would never implement it. It's just that it is an additional code I have to maintain afterwards, for a functionality I'm not completely sold on. It's not a lot of code, honestly, but still.

I'm much more eager to implement buttons for cleaning saved zones or spots, or adding MQTT support so the plugin receives vacuum's status by listening to notifications, rather than having to poll every few seconds. My simple HTTP notifier PR for Valetudo got rejected, so I'm about to set up a standalone MQTT broker at home to test this ecosystem. I've never been a huge fan of MQTT, but I guess it has its uses, for a slight cost of additional infrastructure.

@leonardpitzu
Copy link
Author

Guess you can drop the humidity/battery sensor. In terms of automation you could set up some form of notification and action(e.g. on battery < 30% notify the user and regardless of the task go to the dock). Still this sound more like a useless feature even as I type it. Scrap it.
Regarding MQTT... I am for simple things, few lines of code, etc. thus I would not use it. Still it might be of interest to a lot of people so I guess it is a good idea to do it. Maybe a flag would be nice so one can chose between http and MQTT.

@onfoot
Copy link
Owner

onfoot commented May 10, 2019

The vacuum does stop and go back to base when low on juice - there are even suitable error messages for that. I would know because I recently sent a PR to dustcloud with updated Polish translations. ;)

I'm all for simpler solutions and the HTTP notifications I proposed in the PR would solve some of my issues, but MQTT prevails as THE IoT protocol, apparently.

No worries, though - this plugin will be both HTTP- and MQTT-capable. Once MQTT is configured, I'd like to offer the same exact features, but use a different means of communication.

Here's an idea - maybe I could implement some kind of a status forwarder in the plugin, that, once configured, would post human-readable messages to a predefined URL, to enable push notifications, for example. We could define which status changes should be forwarded, too - I know it spams a lot of these status updates when working, because it does that even for area covered or battery level changes.

Seems like a bit beyond what a Homebridge plugin should do, but then again, one wouldn't have to set up any other ways of getting such notifications.

@leonardpitzu
Copy link
Author

I did something different - scripting based telegram notifications. I have now updated to the latest version - for me it’s mostly ok so I would leave it like this. As of now i am contemplating in baking telegram notification support directly in Valetudo so the vacuum would be self sufficient...

@leonardpitzu
Copy link
Author

Just a question as i have not looked into homebridge (yet). Are there any switch types which support more than 2 states? I am thinking of a multi-level switch - simple press toggles between on/off while long press allows for setting the desired level (e.g. low, medium, high). It would combine the power modes of the vacuum and the ability to turn that particular mode on or off.

@onfoot
Copy link
Owner

onfoot commented May 13, 2019

There is a programmable switch, for example, but its purpose is to have an "intelligent" HomeKit-compatible physical button that can be programmed to perform different actions on a click, double-click and a long-press, so you can't really use it like that in HomeKit, just program the actions performed.

There are other sort of multi-level switches, but very specific ones, like the one for alarm systems - this one has Stay, Away, Night, Disarm, Triggered, so this doesn't make any sense for our purpose. :(

@imbaimbaimba
Copy link

Did you start using MQTT? I would also love to have controls of zones in HomeKit, I just haven't been able to program it myself :(

@onfoot
Copy link
Owner

onfoot commented Nov 15, 2019

I have had zero time available recently, but I've been thinking about the zone cleanups, and it's doable provided that the plugin can indeed associate current action with cleaning the chosen zone when checking for vacuum's status.

As for MQTT, I'd love to implement it for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants