ioBroker.shelly icon indicating copy to clipboard operation
ioBroker.shelly copied to clipboard

TRV Profile bearbeiten

Open MarkoP2507 opened this issue 1 year ago • 8 comments

I'm sure that

  • [X] This issue is still present in the current beta version of this adapter
  • [X] There is no other (open) issue with the same topic (used the search)
  • [X] This issue is not described in the adapter documentation / FAQ

Shelly device

Shelly TRV Firmware 20220811-152343/v2.1.8@5afc928c

Protocol (CoAP / MQTT)

MQTT

The problem

Ist es möglich die Profile zu laden und zu bearbeiten?

das habe ich gefunden auf der Seite von shelly

https://shelly-api-docs.shelly.cloud/gen1/#shelly-trv-settings-thermostats-0

GET /settings/thermostats/0

{
    "target_t": {
        "enabled": true,
        "value": 31.0,
        "units": "C"
    },
    "schedule": false,
    "schedule_profile": 2,
    "schedule_profile_names": [
        "Livingroom",
        "Livingroom 1",
        "Bedroom",
        "Bedroom 1",
        "Holiday"
    ],
    "schedule_rules": [
        "0600-0123456-23",
        "0830-0123456-18",
        "1630-0123456-23",
        "2300-0123456-18"
    ],
    "temperature_offset": 0.0,
    "ext_t": {
        "enabled": false,
        "floor_heating": false
    },
    "t_auto": { 
        "enabled": true
    },
    "boost_minutes": 30,
    "valve_min_percent": 0,
    "force_close": false,
    "calibration_correction": true,
    "extra_pressure": false,
    "open_window_report": false
}

Version of nodejs

v16.19.1

Version of ioBroker js-controller

4.0.24

Version of Adapter

6.4.1

Operating system running ioBroker

linux

Checklist of files to include below

  • [X] iobroker.current.log (Please share the logs in debug mode)
  • [ ] Contents of the JavaScript browser console (always include in cases of issues with the user interface)

Additional information & file uploads

No response

MarkoP2507 avatar Jun 24 '23 14:06 MarkoP2507

Thanks for reporting @MarkoP2507!

  1. Check if this topic is not covered in the documentation
  2. Ensure that you use the latest beta version: NPM version
  3. Attach all necessary log files in debug mode, screenshots and other information to reproduce this issue
  4. Search for the issue topic in other/closed issues to avoid duplicates!

github-actions[bot] avatar Jun 24 '23 14:06 github-actions[bot]

Du kannst Profile über den Adapter auswählen. Was ist denn der Wunsch? Dass man ein Profil über den ioBroker bearbeiten/erstellen kann?

klein0r avatar Jun 26 '23 06:06 klein0r

Genau die Profile über ioBroker bearbeiten, dann habe ich die Möglichkeit das über VIS einzustellen.

MarkoP2507 avatar Jun 26 '23 15:06 MarkoP2507

@klein0r und gibt es schon etwas neues zu diesem Thema ?

MarkoP2507 avatar Oct 03 '23 12:10 MarkoP2507

Von meiner Seite wird da nichts kommen

klein0r avatar Oct 03 '23 13:10 klein0r

Ich habe mir das ein bisschen angeschaut, leider habe ich nicht viel Ahnung von Programmieren.

Ich habe nun ein wenig versucht einen Anfang zu machen.

Ich würde mich freuen wenn dieses Jemand überprüfen würde und intrigieren kann.

const profileNames = {
  "Livingroom",
  "Livingroom 1",
  "Bedroom",
  "Bedroom 1",
  "Holiday",
};

'schedule.profile': {
  coap: {
    http_publish: '/status',
    http_publish_funct: value => {
      const selectedProfile = value ? JSON.parse(value).thermostats[0].schedule_profile : undefined;
      return selectedProfile !== undefined ? profileNames.indexOf(selectedProfile) + 1 : undefined;
    },
    http_cmd: '/settings/thermostat/0',
    http_cmd_funct: value => ({ schedule: 1, schedule_profile: value }),
  },
  mqtt: {
    http_publish: '/status',
    http_publish_funct: value => {
      const selectedProfile = value ? JSON.parse(value).thermostats[0].schedule_profile : undefined;
      return selectedProfile !== undefined ? profileNames.indexOf(selectedProfile) + 1 : undefined;
    },
    http_cmd: '/settings/thermostat/0',
    http_cmd_funct: value => ({ schedule: 1, schedule_profile: value }),
  },
  common: {
    name: 'Schedule Profile',
    type: 'number',
    role: 'Wert',
    read: true,
    write: true,
    min: 1,
    max: profileNames.length,
    states: profileNames,
  },
}

MarkoP2507 avatar Oct 03 '23 15:10 MarkoP2507

Also möchtest Du das Profil per Name setzen können, und gar nicht das Profil selbst im ioBroker bearbeiten?

klein0r avatar Oct 04 '23 07:10 klein0r

Doch mein Idee ist für die VIS Darstellung beides zuhaben.

ich habe noch ein wenig versucht was zu machen.

Ich hoffe damit kann Du etwas anfangen!

Dieses Bereich soll es alles in einzelne Datenpunkte legen!

'schedule.schedule_rules': {
    coap: {
        http_publish: '/status',
        http_publish_funct: value => {
            if (value) {
                const rules = JSON.parse(value).schedule_rules;
                return rules.map(rule => {
                    const [time, days, temperature] = rule.split('-');
                    return {
                        time: `${time.slice(0, 2)}:${time.slice(2)}`,
                        days: parseInt(days, 5).toString(2).padStart(7, '0').split('').reverse().map((d, index) => (d === '1' ? index : null)).filter(d => d !== null),
                        temperature: `${temperature}°C`
                    };
                });
            }
            return undefined;
        },
        http_cmd: '/settings/thermostat/0',
        http_cmd_funct: value => {
            const rules = value.map(rule => {
                const time = rule.time.replace(':', '');
                const days = rule.days.reduce((acc, day) => acc + Math.pow(2, day), 0).toString(5);
                const temperature = parseInt(rule.temperature);
                return `${time}-${days}-${temperature}`;
            });
            return { schedule_rules: rules };
        },
    },
    mqtt: {
        http_publish: '/status',
        http_publish_funct: value => {
            if (value) {
                const rules = JSON.parse(value).schedule_rules;
                return rules.map(rule => {
                    const [time, days, temperature] = rule.split('-');
                    return {
                        time: `${time.slice(0, 2)}:${time.slice(2)}`,
                        days: parseInt(days, 5).toString(2).padStart(7, '0').split('').reverse().map((d, index) => (d === '1' ? index : null)).filter(d => d !== null),
                        temperature: `${temperature}°C`
                    };
                });
            }
            return undefined;
        },
        http_cmd: '/settings/thermostat/0',
        http_cmd_funct: value => {
            const rules = value.map(rule => {
                const time = rule.time.replace(':', '');
                const days = rule.days.reduce((acc, day) => acc + Math.pow(2, day), 0).toString(5);
                const temperature = parseInt(rule.temperature);
                return `${time}-${days}-${temperature}`;
            });
            return { schedule_rules: rules };
        },
    },
    common: {
        name: 'Schedule Rules',
        type: 'array',
        role: 'state',
        read: true,
        write: true,
        states: {
            time: {
                type: 'string',
                role: 'text',
                read: true,
                write: true
            },
            days: {
                type: 'array',
                role: 'state',
                read: true,
                write: true,
                states: {
                    day: {
                        type: 'boolean',
                        role: 'state',
                        read: true,
                        write: true
                    }
                }
            },
            temperature: {
                type: 'string',
                role: 'level.temperature',
                read: true,
                write: true,
                unit: '°C'
            }
        }
    },
},

MarkoP2507 avatar Oct 04 '23 17:10 MarkoP2507