New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

I have a switch named "Terras verlichting". It is not an On/Off switch but a dimmer. How can i change the icon op the display so i can also set a value or slider?
Thanks
Attachments
Display_dash.jpg
Display_dash.jpg (181.13 KiB) Viewed 12563 times
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

@Rik60

So ATM the device is reconised as simple light, without dimmer feature ?

Can you give me some information about the device ?
The code set a Dimmer if
- type = "Light/Switch"
- subtype = "Switch"
- switchtype = "Dimmer"

You can see thoses information on the device widget in domoticz or using a browser

Code: Select all

http://IP:PORT/json.htm?type=command&param=getdevices&rid=ID
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

"Type" : "Lighting 2",
"SubType" : "AC",
"SwitchType" : "Dimmer",

The device is a light, remote controlled by "Klik aan Klik uit" on 433Mhz.
Thanks
Attachments
Terras_verlichting.jpg
Terras_verlichting.jpg (17.31 KiB) Viewed 12312 times
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

Ok so make a search on (you will found it in data_setup.cpp around line 457

Code: Select all

else if (strncmp(type, "Lighting", 8) == 0)
and edit the block to have

Code: Select all

        else if (strncmp(type, "Lighting", 8) == 0)
        {
            d->type = TYPE_LIGHT;
            
            const char* switchtype = i["SwitchType"];
            if (strcmp(switchtype,"Dimmer") == 0)
            {
                d->type = TYPE_DIMMER;
            }
        }
And BTW what mean the "AC" ? alternative current ?
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Thanks,
I have a slider now, but i can't control the light intensity with it, even when i move it. The slider is moving when i control the intensity from another device (computer). On the display dashboard there is no indication now that the lamp is on or off.
AC is, in this case, is how to transmit a code for a specific device, how the code is build.
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

Here I don't see the problem, perhaps someting specific to this device ? But return are working ...
When I try to send command to domoticz I m using the API

Code: Select all

/json.htm?type=command&param=switchlight&idx=IDX&switchcmd=Set%%20Level&level=LEVEL
The result in domoticz is

Code: Select all

2026-03-02 16:46:40.865  Status: User: admin (IP: 192.168.1.29) initiated a switch command (36/Deconz - Dimmer salon/Set Level)
2026-03-02 16:46:40.911  Deconz: onCommand called for Unit 8: Parameter 'Set Level', Level: 69, Hue: 
2026-03-02 16:46:43.897  Status: User: admin (IP: 192.168.1.29) initiated a switch command (36/Deconz - Dimmer salon/Set Level)
2026-03-02 16:46:43.926  Deconz: onCommand called for Unit 8: Parameter 'Set Level', Level: 28, Hue: 
2026-03-02 16:46:48.828  Status: User: admin (IP: 192.168.1.29) initiated a switch command (36/Deconz - Dimmer salon/Set Level)
2026-03-02 16:46:48.831  Deconz: onCommand called for Unit 8: Parameter 'Set Level', Level: 79, Hue: 
2026-03-02 16:47:12.564  Status: User: admin (IP: 192.168.1.29) initiated a switch command (36/Deconz - Dimmer salon/Set Level)
2026-03-02 16:47:12.574  Deconz: onCommand called for Unit 8: Parameter 'Set Level', Level: 51, Hue: 
Have made the try on a deconz dimmer.

You haven't an error message ?
On the display dashboard there is no indication now that the lamp is on or off
You haven't a small "on" when the device is on ?

Here I m checking "Data" value in

Code: Select all

http://IP:PORT/json.htm?type=command&param=getdevices&rid=ID
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

@Rik60 you had some time to make test with the API to see where the problem is from ?
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Sorry, spent a lot a time for another domoticz issue.
Attached a domoticz log whart domoticz is receiving from the display, nowether the possition of the slider is, received is always a level of 31?
And on the dashboard of the display there is no indication that the lamp is on.
Thanks
Attachments
Sunton_receiveInDomoticz.jpg
Sunton_receiveInDomoticz.jpg (297.08 KiB) Viewed 12165 times
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

31 is the device ID ^^.
On my side I have

Code: Select all

2026-03-02 16:47:12.564  Status: User: admin (IP: 192.168.1.29) initiated a switch command (36/Deconz - Dimmer salon/Set Level)
2026-03-02 16:47:12.574  Deconz: onCommand called for Unit 8: Parameter 'Set Level', Level: 51, Hue:
The 36 value is always the same.

I will try to simulate your device on Domoticz but without the hardware Im not sure it will work.

Can you share the complete devince json from domoticz ?

Code: Select all

http://IP:PORT/json.htm?type=command&param=getdevices&rid=31
Perhaps you are concerned by
Level should be the dim level (not percentage), like 0-16 or 0-100 depending on the hardware used
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

It is a bit strange, if the lamp is on and tap on the diplay for a low lamp setting it is working but the value is never the same.
The displayed range on the display is from 0-100%, domoticz is range from 0-100 (without %)
I never see that the level is set a a level, in your case the level is set at 51.
Attached the complete device json and some domoticz logging.
The display i use is an ESP32S3-8043S043
Attachments
Sunton_display_receive_2.jpg
Sunton_display_receive_2.jpg (82.07 KiB) Viewed 12045 times
TerrasVerlichtingDomoticz.txt
(1.65 KiB) Downloaded 646 times
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

I never see that the level is set a a level, in your case the level is set at 51
Yeah it's from the hardware, can be different for all of them, in this exemple it's a message from the python plugin.

Code: Select all

"Data" : "Off",
Same than me, and it's "On" when the light is on ?
The code just check for value "On" (not for "Off"), if it's "On" it's power on, in all other situation it's power off.

But here

Code: Select all

			"Level" : 40,
			"LevelInt" : 6,
			"MaxDimLevel" : 15,
For me the max level is 100, not 15. I think domoticz is using a 0/100 value but make a convertion at a moment (6 = 40% of 15)
And from the API
Level should be the dim level (not percentage), like 0-16 or 0-100 depending on the hardware used
So can you make try with values from 0 to 15 max to test?
The code check for "level" value, so if you send a level = 6, the hardware will see 40 in websocket return, so the slider will move itself to position 40.
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Did some tests:
slider display slider domoticz
13 13
6 6
19 100
9 -> 60 60 set the display slider on 9, slider domoticz -> 60, slider display ->60
93 93
3 -> 20 20
There is never "On" on the display dashboard that the lamp is on.
If i set the slider in domoticz on a value, the slider on the display is then always on that value.
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

20% of 15 = 3
60% 15 = 9
9 -> 60
60 set the display slider on 9, slider domoticz -> 60, slider display ->60
You send the request with level = 9/15, domoticz convert it in percent = 60%, and the device display the 60%

So it's seem to be the problem, have updated the code on branch "test"
https://github.com/Smanar/CYD-Domoticz- ... e552886c6c

I think it will solve the level problem.

For the "On" never displayed, I realy have no clue ...
Can you check what is the "Data" value when the light is powered on the device json ?

Code: Select all

			"CustomImage" : 0,
			"Data" : "Off",
			"Description" : "",
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Thanks, that slider problem is solved. Level on the display is now always the same as in Domoticz.

If i switch the lamp off, data is " Off", if the lamp is on at a level, data is "Set level: 46%". 46 is the level at that moment.

Next to the slider on the right there is a small On/Off switch slider.
If i move that switch to the right the lamp goes on and the switch stays On. If i switch the lamp off in Domoticz the lamp goes off and the switch is moving to its off position. If i then turn the lamp on in Domoticz the switch on the diaplay stays in its off position.

I never see "On" on the dashboard. It was in earlier version of the software, this problem occurd when the slider was introduced.
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

If i switch the lamp off, data is " Off", if the lamp is on at a level, data is "Set level: 46%".
Ok so I think you have found the problerm

On device_panel.cpp around line 409, replace

Code: Select all

if (strcmp(SelectedDevice->data, "On") == 0)
By

Code: Select all

if (strcmp(SelectedDevice->data, "Off") != 0)
In Home_panel.cpp around line 113, replace

Code: Select all

if (d->type < TYPE_SWITCH && strcmp(d->data, "On") == 0)
by

Code: Select all

if (d->type < TYPE_SWITCH && strcmp(d->data, "Off") != 0)
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Yes, it's working now. Slider is ok, and on the display's dashboard the lamp is "On" when the lamp is switched on.
Just a thought, is it possible to have a push button as On/Off switch? Now it's a slider switch next to the level slider
Thanks
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

Nice, the updated code is not yet online, but next versin will include your changes.

Code: Select all

is it possible to have a push button as On/Off switch? Now it's a slider switch next to the level slider
Ha yes, the defaut "button" is a switch (a little slider with 2 positions) not a button, but it's the defaut one, for device making only on/off it's possible to switch them direclty on home page, but as this one have slider too, you have the "switch".

But what is the problem with it ? It's just visual, it's not a slider, on press toggle the state, there is no mouvement to done. It's like a button with 2 states ?
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

You are right. I thought that it was a slider. If i press it, it's toggles.
Is it possible to have the switch on the same high (line) as the level slider? I think it looks nicer.
Thanks for all your work.
Thorgal789
Posts: 919
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

I can't make it general but it's fast.
In device_panel.cpp around line 499, replace

Code: Select all

lv_obj_center(slider);
by

Code: Select all

lv_obj_align(slider, LV_ALIGN_CENTER, 0, -19);
Rik60
Posts: 228
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2026.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

I have changed:

Code: Select all

lv_obj_center(slider);
into

Code: Select all

lv_obj_align(slider, LV_ALIGN_CENTER, 0, -31);
I think it's nicer...
Thanks
Attachments
Sliders_aligned.jpg
Sliders_aligned.jpg (220.79 KiB) Viewed 11608 times
Post Reply