Weekly programming

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

DarkG
Posts: 89
Joined: Friday 15 September 2017 18:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10076
Location: Germany
Contact:

Re: Weekly programming

Post by DarkG »

Will this work with the lastest beta?
RPi4 Shelly1 Shelly2.5 ESPEasy Tuya Domoticz Beta Dashticz 3.6
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Absolutely, it does.
Do you have a trouble with it?
DarkG
Posts: 89
Joined: Friday 15 September 2017 18:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10076
Location: Germany
Contact:

Re: Weekly programming

Post by DarkG »

I ask to be safe. My system is good running. And I dont wanna crash it. So I ask before İ try.

But after Update it get lost or? So everytime I Update my System I must Install it again. İ am on Beta Channel
RPi4 Shelly1 Shelly2.5 ESPEasy Tuya Domoticz Beta Dashticz 3.6
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

As this is not in the master branch, after each updates, you have to modify the DeviceTimersController.js file to add the 3 parts as explained on my github gist.
User avatar
EdddieN
Posts: 510
Joined: Wednesday 16 November 2016 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Scotland
Contact:

Re: Weekly programming

Post by EdddieN »

WoW!

That is great
11101101 - www.machinon.com
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

A new version is released on my github.

This is a "ready to branch" version, easier to integrate with existing code.
I improve performance and fix some issues.

WARNING, planning.js is now on www/app/timers folder
DarkG
Posts: 89
Joined: Friday 15 September 2017 18:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10076
Location: Germany
Contact:

Re: Weekly programming

Post by DarkG »

Can you please look why there are no icons?

https://www.bilder-upload.eu/bild-ed014 ... 7.jpg.html
RPi4 Shelly1 Shelly2.5 ESPEasy Tuya Domoticz Beta Dashticz 3.6
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

did you delete the application cache of your web browser?
if you press F12 (to open developpement tools) and go to the console tab, you should see an error. Check it and let me know.
DarkG
Posts: 89
Joined: Friday 15 September 2017 18:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10076
Location: Germany
Contact:

Re: Weekly programming

Post by DarkG »

syrhus wrote: Saturday 22 December 2018 11:53 did you delete the application cache of your web browser?
if you press F12 (to open developpement tools) and go to the console tab, you should see an error. Check it and let me know.
Here you can see

https://www.bilder-upload.eu/bild-f4c5e ... 9.jpg.html
RPi4 Shelly1 Shelly2.5 ESPEasy Tuya Domoticz Beta Dashticz 3.6
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Could you show your DeviceTimersController.js file?
It seems you have something wrong in this fils in the getTimers function.
DarkG
Posts: 89
Joined: Friday 15 September 2017 18:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10076
Location: Germany
Contact:

Re: Weekly programming

Post by DarkG »

Code: Select all

define(['app', 'timers/factories', 'timers/components','timers/planning' ], function (app) {

    app.controller('DeviceTimersController', function ($scope, $routeParams, deviceApi, deviceLightApi, deviceRegularTimersApi, deviceSetpointTimersApi, deviceTimerOptions, deviceTimerConfigUtils, utils) {
        var vm = this;
        var deviceTimers;

        var deleteConfirmationMessage = $.t('Are you sure to delete this timers?\n\nThis action can not be undone...');
        var clearConfirmationMessage = $.t('Are you sure to delete ALL timers?\n\nThis action can not be undone!');

        vm.addTimer = addTimer;
        vm.updateTimer = updateTimer;
        vm.deleteTimer = utils.confirmDecorator(deleteTimer, deleteConfirmationMessage);
        vm.clearTimers = utils.confirmDecorator(clearTimers, clearConfirmationMessage);

        init();

        function init() {
            vm.deviceIdx = $routeParams.id;
            vm.selectedTimerIdx = null;

            deviceApi.getDeviceInfo(vm.deviceIdx).then(function (device) {
                vm.isLoaded = true;
                vm.itemName = device.Name;
                vm.colorSettingsType = device.SubType;
                vm.dimmerType = device.DimmerType;

                vm.isDimmer = device.isDimmer();
                vm.isSelector = device.isSelector();
                vm.isLED = device.isLED();
                vm.isCommandSelectionDisabled = vm.isSelector && device.LevelOffHidden;
                vm.isSetpointTimers = (device.Type === 'Thermostat' && device.SubType == 'SetPoint') || (device.Type === 'Radiator 1');

                vm.levelOptions = [];

                deviceTimers = vm.isSetpointTimers
                    ? deviceSetpointTimersApi
                    : deviceRegularTimersApi;

                if (vm.isSelector) {
                    vm.levelOptions = device.getSelectorLevelOptions();
                }

                if (vm.isLED) {
                    $scope.$watch(function () {
                        return vm.timerSettings.color + vm.timerSettings.level;
                    }, setDeviceColor);
                }

                if (vm.isDimmer) {
                    vm.levelOptions = device.getDimmerLevelOptions(1);
                }

                if (vm.levelOptions.length > 0) {
                    vm.timerSettings.level = vm.levelOptions[0].value;
                }

                refreshTimers();
            });

            vm.typeOptions = deviceTimerOptions.timerTypes;
            vm.timerSettings = deviceTimerConfigUtils.getTimerDefaultConfig();
			 $( document ).trigger( "timersInitialized", [vm, refreshTimers] );//<===Update for Planning
             refreshTimers();
        }

        function refreshTimers() {
            vm.selectedTimerIdx = null;

            deviceTimers.getTimers(vm.deviceIdx).then(function (items) {
                vm.timers = items;
				$( document ).trigger( "timersLoaded", [items] );;//<===Update for Planning
            });
        }

        function setDeviceColor() {
            if (!vm.timerSettings.color || !vm.timerSettings.level) {
                return;
            }

            deviceLightApi.setColor(
                vm.deviceIdx,
                vm.timerSettings.color,
                vm.timerSettings.level
            );
        }

        function getTimerConfig() {
            var utils = deviceTimerConfigUtils;
            var config = Object.assign({}, vm.timerSettings);

            if (!utils.isDayScheduleApplicable(config.timertype)) {
                config.days = 0;
            }

            if ([6, 7, 10, 12].includes(config.timertype)) {
                config.days = 0x80;
            }

            if (utils.isOccurrenceApplicable(config.timertype)) {
                config.days = Math.pow(2, config.weekday);
            }

            config = Object.assign({}, config, {
                date: utils.isDateApplicable(config.timertype) ? config.date : undefined,
                mday: utils.isRDaysApplicable(config.timertype) ? config.mday : undefined,
                month: utils.isRMonthsApplicable(config.timertype) ? config.month : undefined,
                occurence: utils.isOccurrenceApplicable(config.timertype) ? config.occurence : undefined,
                weekday: undefined,
                color: vm.isLED ? config.color : undefined,
                tvalue: vm.isSetpointTimers ? config.tvalue : undefined,
                command: vm.isSetpointTimers ? undefined : config.command,
                randomness: vm.isSetpointTimers ? undefined : config.randomness
            });

            var error = deviceTimerConfigUtils.getTimerConfigErrors(config);

            if (error) {
                ShowNotify(error, 2500, true);
                return false;
            }

            var warning = deviceTimerConfigUtils.getTimerConfigWarnings(config);

            if (warning) {
                ShowNotify(error, 2500, true);
            }

            return config;
        }

        function addTimer() {
            const config = getTimerConfig();

            if (!config) {
                return false;
            }

            deviceTimers
                .addTimer(vm.deviceIdx, config)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem adding timer!'), 2500, true);
                });
        }

        function updateTimer(timerIdx) {
            const config = getTimerConfig();

            if (!config) {
                return false;
            }

            deviceTimers
                .updateTimer(timerIdx, config)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem updating timer!'), 2500, true);
                });
        }

        function deleteTimer(timerIdx) {
            return deviceTimers.deleteTimer(timerIdx)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem deleting timer!'), 2500, true);
                });
        }

        function clearTimers() {
            return deviceTimers
                .clearTimers(vm.deviceIdx)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem clearing timers!'), 2500, true);
                });
        }
    });
});
RPi4 Shelly1 Shelly2.5 ESPEasy Tuya Domoticz Beta Dashticz 3.6
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Please, check what you have modified, you wrote the wrong for the first trigger:

Code: Select all

define(['app', 'timers/factories', 'timers/components','timers/planning'], function (app) {

    app.controller('DeviceTimersController', function ($scope, $routeParams, deviceApi, deviceLightApi, deviceRegularTimersApi, deviceSetpointTimersApi, deviceTimerOptions, deviceTimerConfigUtils, utils) {
        var vm = this;
        var deviceTimers;

        var deleteConfirmationMessage = $.t('Are you sure to delete this timers?\n\nThis action can not be undone...');
        var clearConfirmationMessage = $.t('Are you sure to delete ALL timers?\n\nThis action can not be undone!');

        vm.addTimer = addTimer;
        vm.updateTimer = updateTimer;
        vm.deleteTimer = utils.confirmDecorator(deleteTimer, deleteConfirmationMessage);
        vm.clearTimers = utils.confirmDecorator(clearTimers, clearConfirmationMessage);

        init();
        
        function init() {
            vm.deviceIdx = $routeParams.id;
            vm.selectedTimerIdx = null;

            deviceApi.getDeviceInfo(vm.deviceIdx).then(function (device) {
                vm.isLoaded = true;
                vm.itemName = device.Name;
                vm.colorSettingsType = device.SubType;
                vm.dimmerType = device.DimmerType;

                vm.isDimmer = device.isDimmer();
                vm.isSelector = device.isSelector();
                vm.isLED = device.isLED();
                vm.isCommandSelectionDisabled = vm.isSelector && device.LevelOffHidden;
                vm.isSetpointTimers = (device.Type === 'Thermostat' && device.SubType == 'SetPoint') || (device.Type === 'Radiator 1');

                vm.levelOptions = [];

                deviceTimers = vm.isSetpointTimers
                    ? deviceSetpointTimersApi
                    : deviceRegularTimersApi;

                if (vm.isSelector) {
                    vm.levelOptions = device.getSelectorLevelOptions();
                }

                if (vm.isLED) {
                    $scope.$watch(function () {
                        return vm.timerSettings.color + vm.timerSettings.level;
                    }, setDeviceColor);
                }

                if (vm.isDimmer) {
                    vm.levelOptions = device.getDimmerLevelOptions(1);
                }

                if (vm.levelOptions.length > 0) {
                    vm.timerSettings.level = vm.levelOptions[0].value;
                }

                $( document ).trigger( "timersInitialized", [vm, refreshTimers] );
                refreshTimers();
            });

            vm.typeOptions = deviceTimerOptions.timerTypes;
            vm.timerSettings = deviceTimerConfigUtils.getTimerDefaultConfig();
        }

        function refreshTimers() {
            vm.selectedTimerIdx = null;

            deviceTimers.getTimers(vm.deviceIdx).then(function (items) {
                vm.timers = items;
                $( document ).trigger( "timersLoaded", [items] );
            });
        }

        function setDeviceColor() {
            if (!vm.timerSettings.color || !vm.timerSettings.level) {
                return;
            }

            deviceLightApi.setColor(
                vm.deviceIdx,
                vm.timerSettings.color,
                vm.timerSettings.level
            );
        }

        function getTimerConfig() {
            var utils = deviceTimerConfigUtils;
            var config = Object.assign({}, vm.timerSettings);

            if (!utils.isDayScheduleApplicable(config.timertype)) {
                config.days = 0;
            }

            if ([6, 7, 10, 12].includes(config.timertype)) {
                config.days = 0x80;
            }

            if (utils.isOccurrenceApplicable(config.timertype)) {
                config.days = Math.pow(2, config.weekday);
            }

            config = Object.assign({}, config, {
                date: utils.isDateApplicable(config.timertype) ? config.date : undefined,
                mday: utils.isRDaysApplicable(config.timertype) ? config.mday : undefined,
                month: utils.isRMonthsApplicable(config.timertype) ? config.month : undefined,
                occurence: utils.isOccurrenceApplicable(config.timertype) ? config.occurence : undefined,
                weekday: undefined,
                color: vm.isLED ? config.color : undefined,
                tvalue: vm.isSetpointTimers ? config.tvalue : undefined,
                command: vm.isSetpointTimers ? undefined : config.command,
                randomness: vm.isSetpointTimers ? undefined : config.randomness
            });

            var error = deviceTimerConfigUtils.getTimerConfigErrors(config);

            if (error) {
                ShowNotify(error, 2500, true);
                return false;
            }

            var warning = deviceTimerConfigUtils.getTimerConfigWarnings(config);

            if (warning) {
                ShowNotify(error, 2500, true);
            }

            return config;
        }

        function addTimer() {
            const config = getTimerConfig();

            if (!config) {
                return false;
            }

            deviceTimers
                .addTimer(vm.deviceIdx, config)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem adding timer!'), 2500, true);
                });
        }

        function updateTimer(timerIdx) {
            const config = getTimerConfig();

            if (!config) {
                return false;
            }

            deviceTimers
                .updateTimer(timerIdx, config)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem updating timer!'), 2500, true);
                });
        }

        function deleteTimer(timerIdx) {
            return deviceTimers.deleteTimer(timerIdx)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem deleting timer!'), 2500, true);
                });
        }

        function clearTimers() {
            return deviceTimers
                .clearTimers(vm.deviceIdx)
                .then(refreshTimers)
                .catch(function () {
                    HideNotify();
                    ShowNotify($.t('Problem clearing timers!'), 2500, true);
                });
        }
    });
});
Last edited by syrhus on Saturday 22 December 2018 13:25, edited 1 time in total.
DarkG
Posts: 89
Joined: Friday 15 September 2017 18:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10076
Location: Germany
Contact:

Re: Weekly programming

Post by DarkG »

RPi4 Shelly1 Shelly2.5 ESPEasy Tuya Domoticz Beta Dashticz 3.6
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

I changed the previous post to set the entire DeviceTimersController.js file
Please replace it with your one and keep in mind that each time you change a js file, you have to clear your application cache to reload the updated files.
ocean123

Re: Weekly programming

Post by ocean123 »

wouw, great tool. Thanks :D
ocean123

Re: Weekly programming

Post by ocean123 »

I add the script to Domoticz version 4.10717.
And its not working. After restart also not.
No error, no changes, nothing happens.

:shock:
ocean123

Re: Weekly programming

Post by ocean123 »

It has something to do with Safari.
Chrome is working fine, Private browsing in Safari also working fine.
But normale browsing in safari, the scheduler is not showing up.
ocean123

Re: Weekly programming

Post by ocean123 »

Now its showing up. :D
Domoticz refreshed the browser cache the next day.

Image
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Weekly programming

Post by salopette »

@ syrhus

can you do PR for Domoticz?

https://github.com/domoticz/domoticz/is ... -515738984
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Weekly programming

Post by salopette »

salopette wrote: Sunday 28 July 2019 9:36 @ syrhus

can you do PR for Domoticz?

https://github.com/domoticz/domoticz/is ... -515738984
:?: :?: :roll:
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest