HASwitchPlate / openHASP

HomeAutomation Switchplate based on lvgl for ESP32
https://www.openhasp.com
MIT License
695 stars 179 forks source link

parentid dont work #704

Closed matsekberg closed 5 months ago

matsekberg commented 5 months ago

Perform all steps below and tick them with [x]

Describe the bug

I try to reduce the size of configuration by using parent objects but cant get it to work. Only objects with explicit properties displays correct.

To Reproduce

This is the config:

{"page":4,"id":99,"obj":"btn","x":0,"y":0,"h":0,"w":0,"toggle":1,"bg_color90":"#880000","bg_color91":"#005500","bg_color92":"#00FF00","bg_color93":"#FF0000","text_font":24, "radius30":7}
{"id":5,"obj":"btn","x":30,"y":260,"h":64,"w":120,"text":"KYLBOX","parentid":99}
{"id":6,"obj":"btn","x":170,"y":260,"h":64,"w":120,"text":"V.PUMP","parentid":99}
{"id":7,"obj":"btn","x":30,"y":340,"h":64,"w":120,"text":"STEG","parentid":99}
{"id":8,"obj":"btn","x":170,"y":340,"h":64,"w":120,"text":"EXTRA","toggle":1,"bg_color90":"#880000","bg_color91":"#005500","bg_color92":"#00FF00","bg_color93":"#FF0000","text_font":24, "radius30":7}

id 99 is supposed to hold stylings and other common properties. id 5, 6 and 7 has a parentid pointing to the 99 object with common props. id 8 uses explicit same properties.

Expected behavior

The expected behaviour is four buttons with equal styling and size.

Screenshots or video

The image show that only id 8 (with explicit properties) s displayed. p4 Medel

This is the expected design: screenshot-2 Medel

Info

openHASP
Version 0.7.0-rc4 f76dee8
Build DateTime  Apr 15 2023 18:56:32 UTC
Environment esp32-3248s035c_4MB
Uptime  1m 40s
Idle    short
Active Page 4
Device Memory
Free Heap   34.24 KiB
Free Block  29.98 KiB
Fragmentation   12%
LVGL Memory
Total   48.00 KiB
Free    8.06 KiB
Fragmentation   15%
MQTT
Server  10.0.1.50
Username
Client ID   salon_15c350
Status  Connected
Received    318
Published   43
Failed
Module
Model   ESP32-D0WDQ5 rev3
Frequency   240MHz
Core Version    4.4.4.20230218
Reset Reason    CPU0: SW_CPU_RESET / CPU1: SW_CPU_RESET
Flash Size  4.00 MiB
Program Size Used   1.66 MiB
Program Size Free   1.68 MiB
Filesystem Size 560.00 KiB
Filesystem Used 56.00 KiB
Filesystem Free 504.00 KiB
marsman7 commented 5 months ago

Your parent object has a size of zero (w=0 and h=0). The children must fit in it. When you change your object to :

{"page":4,"id":99,"obj":"btn","x":0,"y":0,"h"480,"w":320,"toggle":1,"bg_color90":"#880000","bg_color91":"#005500","bg_color92":"#00FF00","bg_color93":"#FF0000","text_font":24, "radius30":7}

All buttons are visible. But I don't think that's what you want. This is not an bug. It just doesn't work that way. Parents are normally TABVIEWS or PAGES but they don't save "bg_color90":"#880000" or "toggle":1 for example.

matsekberg commented 5 months ago

My understanding from the documentation is that if the child has the same property as the parent, then the child will override. X, y, h and w should be taken from the children.

I could try make the leftmost button a parent and the other children.

fvanroie commented 5 months ago

Some properties (typically that are related to text and opacity) can be inherited, .i.e. not all properties are inheritable. You need to set toggle, bg_color90,bg_color91,bg_color92,bg_color93,radius30 on each button individually. There is no way to group styling properties in the way you are trying to achieve...

You can create a parent obj object and set the text_fontthere once. All x and y coordinates will be relative to the parent.

matsekberg commented 5 months ago

Ok so me trying to use parent as a template won’t work that well. And you see no reason to implement it that way? In order to simplify the config file.

fvanroie commented 5 months ago

Maybe in due time... but you can implement this too if you really needed it. I have made the whole project open source so users can benefit and contribute alike...