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

various minor changes, including managing hidden entities in customization screen #527

Merged
merged 18 commits into from
May 29, 2022

Conversation

proddy
Copy link
Contributor

@proddy proddy commented May 26, 2022

No description provided.

@proddy proddy requested a review from MichaelDvP May 26, 2022 15:50
@@ -464,7 +471,7 @@ const SettingsCustomization: FC = () => {
setMasks(['']);
}}
>
<ToggleButton value="8" disabled={(de.m & 1) !== 0 || de.id === ''}>
<ToggleButton value="8" disabled={(de.m & 1) !== 0 || de.id === '' || de.s === de.id}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the check for === '' is not needed anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good spot

@MichaelDvP
Copy link
Contributor

MichaelDvP commented May 26, 2022

Another point, the reset have short- and fullname "reset", we have to rename to different names now to allow to show in web ui.

And same for some other values with identical texts: heatmetering, pumpkick, doublematchflow, activated, status. Isn't it easier to leave fullname blank and use a combined string(de.id + de.s) as unique key?

@proddy
Copy link
Contributor Author

proddy commented May 26, 2022

Another point, the reset have short- and fullname "reset", we have to rename to different names now to allow to show in web ui.

And same for some other values with identical texts: heatmetering, pumpkick, doublematchflow, activated, status. Isn't it easier to leave fullname blank and use a combined string(de.id + de.s) as unique key?

that's an option. but how would we detect in the web UI if it's a hidden entity or not?

@MichaelDvP
Copy link
Contributor

I have not read the table documentation, so maybe i'm wrong. As you mentioned the unique id i thought this is this key: https://github.com/emsesp/EMS-ESP32/blob/9d25f8049c92b024e33c0bceefc66306a008018d/interface/src/project/SettingsCustomization.tsx#L453
And changing to key={de.id + de.s} should make the key unique also with empty id.

@proddy
Copy link
Contributor Author

proddy commented May 27, 2022

I have not read the table documentation, so maybe i'm wrong. As you mentioned the unique id i thought this is this key: https://github.com/emsesp/EMS-ESP32/blob/9d25f8049c92b024e33c0bceefc66306a008018d/interface/src/project/SettingsCustomization.tsx#L453 And changing to key={de.id + de.s} should make the key unique also with empty id.

the data object takes an array of nodes which must contain the id property. It's internally and not the key attribute of the map function. The solution I'll use for hidden entities is using a special char in the name (like a *) and handle the check in the typescript code

@proddy
Copy link
Contributor Author

proddy commented May 27, 2022

ok Michael, think this should work now

obj["s"] = dv.short_name;
// n is the fullname, and can be optional
// don't add the fullname if its a command
if (dv.type != DeviceValueType::CMD) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you skip the fullname for commands? I think show them as normal and delete line 842/843/853

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is only one command, in the boiler called reset and it shows up in the Customizations as reset (reset) which is silly. The shortname is also not relevant as it's not part of the API and MQTT. If you think we still need to show the shortname then I would suggest changing the fullname to something more descriptive like 'reset command' ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you skip the fullname for command and so it's handled as hidden, but it is not hidden, we want to have all options to show in web. Since you are using now the shortname as id, you can not skip the shortname.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can modify formatName() to

    if (de.n === undefined || de.n === de.id) {
      return de.id;

to avoid "reset (reset)" and "pumpkick (pumpkick)", "activated (activated)", etc. This have no effect to the customization logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that's a much better option. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sending the entity fullname if its a command as this is the only way the Customizations web page knows whether it's a command or not.

@MichaelDvP
Copy link
Contributor

MichaelDvP commented May 28, 2022

You are mixing commands and hidden values with the result that now both are not working correctly.
Why not add a de.c for commands, like in dashboard, or use de.n undefined for hidden and de.n empty for commands, but not the same for both.
Correction: the de.c in dashboard is different aand not commandonly. don't use this to avoid misunderstanding.,

@proddy
Copy link
Contributor Author

proddy commented May 28, 2022

You are mixing commands and hidden values with the result that now both are not working correctly. Why not add a de.c for commands, like in dashboard, or use de.n undefined for hidden and de.n empty for commands, but not the same for both. Correction: the de.c in dashboard is different aand not commandonly. don't use this to avoid misunderstanding.,

not sure I follow. It works for me. What is a 'hidden' entity?

@MichaelDvP
Copy link
Contributor

not sure I follow. It works for me. What is a 'hidden' entity?

hidden iswhat you have introduced for id and ha-mode, a entitiy not shown in the web with missing fullname. Now it's only the climate generation, not shown in web and mqtt, no command but customization button for mqtt/api to disable the climate generation. Shoul look like this:
grafik

The command reset does not show in mqtt (but is subscribed via wildcard), because it have no value, but shows in web to send the right command. It is and has a command, so we could disable write, but than it should also disable the web. Should look like this:
grafik

But you handle both the same way without fullname.

I'm using now de.n undefined for hidden and de.n empty for command:

        if (dv.type == DeviceValueType::CMD) {
            obj["n"] = "";
  function formatName(de: DeviceEntity) {
    if (de.n === undefined || de.n === de.id) {
      return de.id;
    } else if (de.n === '') {
      return 'Command: ' + de.id;
    }
    return de.n + ' (' + de.id + ')';
  }
                          if (de.n === '' && (de.m & DeviceEntityMask.DV_READONLY)) {
                            de.m = de.m | DeviceEntityMask.DV_WEB_EXCLUDE;
                          }
                          if (de.m & DeviceEntityMask.DV_WEB_EXCLUDE) {
                            de.m = de.m & ~DeviceEntityMask.DV_FAVORITE;
                          }
                          setMasks(['']);
                        }}
                      >
                        <ToggleButton value="8" disabled={(de.m & 1) !== 0 || de.n === undefined}>
                          <StarIcon sx={{ fontSize: 14 }} />
                        </ToggleButton>
                        <ToggleButton value="4" disabled={!de.w || (de.m & 3) === 3}>
                          <EditOffOutlinedIcon sx={{ fontSize: 14 }} />
                        </ToggleButton>
                        <ToggleButton value="2" disabled={de.n === ''}>
                          <CommentsDisabledOutlinedIcon sx={{ fontSize: 14 }} />
                        </ToggleButton>
                        <ToggleButton value="1" disabled={de.n === undefined}>
                          <VisibilityOffOutlinedIcon sx={{ fontSize: 14 }} />
                        </ToggleButton>
                      </ToggleButtonGroup>

@proddy
Copy link
Contributor Author

proddy commented May 28, 2022

wow, you know the code better than I do. I'll incorporate your changes. One last thing, should we show the value for ha/climate creation. Now it looks like:

image

@MichaelDvP
Copy link
Contributor

Yes, i think leave the value to climate, it's a good feedback that it's active and shows the right value. (as you see above in my screenshot for ha disabled the value is empty).

@proddy
Copy link
Contributor Author

proddy commented May 29, 2022

Yes, i think leave the value to climate, it's a good feedback that it's active and shows the right value. (as you see above in my screenshot for ha disabled the value is empty).

ok, so if you're ok with PR can you approve and merge it? (or I'll do it, either way)

@proddy proddy requested a review from MichaelDvP May 29, 2022 07:14
@proddy proddy merged commit e65f507 into emsesp:dev May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants