mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
refactor screensaver
This commit is contained in:
413
HMI/README.md
413
HMI/README.md
@@ -94,9 +94,418 @@ change the page type:
|
||||
|
||||
### screensaver page
|
||||
|
||||
`weatherUpdate~tMainIcon~tMainText~tForecast1~tF1Icon~tForecast1Val~tForecast2~tF2Icon~tForecast2Val~tForecast3~tF3Icon~tForecast3Val~tForecast4~tF4Icon~tForecast4Val~optionalLayoutIcon~optionalLayoutText~altIconFont~altIconFont`
|
||||
Example default layout: `weatherUpdate~~~A~21130~~-0.7C~~~B~63469~Sat~3.6C~~~C~35957~Sun~3.9C~~~D~31728~Mon~4.3C~~~E~35957~Tue~3.6C`
|
||||
Example alternative layout: `weatherUpdate~~~A~21130~~-0.7C~~~B~63469~Sat~3.6C~~~C~35957~Sun~3.9C~~~D~31728~Mon~4.3C~~~E~35957~Tue~3.6C~~~F~21130~~23.6C`
|
||||
|
||||
`color~background~time~timeAMPM~date~tMainIcon~tMainText~tForecast1~tForecast2~tForecast3~tForecast4~tF1Icon~tF2Icon~tF3Icon~tF4Icon~tForecast1Val~tForecast2Val~tForecast3Val~tForecast4Val~bar~tMRIcon~tMR`
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter Number</th>
|
||||
<th>Category</th>
|
||||
<th>Location</th>
|
||||
<th>Type</th>
|
||||
<th>Field</th>
|
||||
<th>Addional Information</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>0</td>
|
||||
<td>instruction</td>
|
||||
<td></td>
|
||||
<td>instruction</td>
|
||||
<td>weatherupdate</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td></td>
|
||||
<td rowspan="6">Main Icon</td>
|
||||
<td rowspan="6">Entity Definition</td>
|
||||
<td>type</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td></td>
|
||||
<td>intNameEntity</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td></td>
|
||||
<td>icon</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td></td>
|
||||
<td>iconColor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5</td>
|
||||
<td></td>
|
||||
<td>displayName</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td></td>
|
||||
<td>optionalValue</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>7</td>
|
||||
<td></td>
|
||||
<td rowspan="6">First Forecast Icon</td>
|
||||
<td rowspan="6">Entity Definition</td>
|
||||
<td>type</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>8</td>
|
||||
<td></td>
|
||||
<td>intNameEntity</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>9</td>
|
||||
<td></td>
|
||||
<td>icon</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>10</td>
|
||||
<td></td>
|
||||
<td>iconColor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>11</td>
|
||||
<td></td>
|
||||
<td>displayName</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>12</td>
|
||||
<td></td>
|
||||
<td>optionalValue</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>13</td>
|
||||
<td></td>
|
||||
<td rowspan="6">Second Forecast Icon</td>
|
||||
<td rowspan="6">Entity Definition</td>
|
||||
<td>type</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>14</td>
|
||||
<td></td>
|
||||
<td>intNameEntity</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>15</td>
|
||||
<td></td>
|
||||
<td>icon</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>16</td>
|
||||
<td></td>
|
||||
<td>iconColor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>17</td>
|
||||
<td></td>
|
||||
<td>displayName</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>18</td>
|
||||
<td></td>
|
||||
<td>optionalValue</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>19</td>
|
||||
<td></td>
|
||||
<td rowspan="6">Third Forecast Icon</td>
|
||||
<td rowspan="6">Entity Definition</td>
|
||||
<td>type</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>20</td>
|
||||
<td></td>
|
||||
<td>intNameEntity</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>21</td>
|
||||
<td></td>
|
||||
<td>icon</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>22</td>
|
||||
<td></td>
|
||||
<td>iconColor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>23</td>
|
||||
<td></td>
|
||||
<td>displayName</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24</td>
|
||||
<td></td>
|
||||
<td>optionalValue</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>25</td>
|
||||
<td></td>
|
||||
<td rowspan="6">Fourth Forecast Icon</td>
|
||||
<td rowspan="6">Entity Definition</td>
|
||||
<td>type</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>26</td>
|
||||
<td></td>
|
||||
<td>intNameEntity</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>27</td>
|
||||
<td></td>
|
||||
<td>icon</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>28</td>
|
||||
<td></td>
|
||||
<td>iconColor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>29</td>
|
||||
<td></td>
|
||||
<td>displayName</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>30</td>
|
||||
<td></td>
|
||||
<td>optionalValue</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>31</td>
|
||||
<td></td>
|
||||
<td rowspan="6">Alternative Layout Icon</td>
|
||||
<td rowspan="6">Entity Definition</td>
|
||||
<td>type</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>32</td>
|
||||
<td></td>
|
||||
<td>intNameEntity</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>33</td>
|
||||
<td></td>
|
||||
<td>icon</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>34</td>
|
||||
<td></td>
|
||||
<td>iconColor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>35</td>
|
||||
<td></td>
|
||||
<td>displayName</td>
|
||||
<td>ignored</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>36</td>
|
||||
<td></td>
|
||||
<td>optionalValue</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
`color~background~tTime~timeAMPM~tDate~tMainText~tForecast1~tForecast2~tForecast3~tForecast4~tForecast1Val~tForecast2Val~tForecast3Val~tForecast4Val~bar~tMainTextAlt2~tMR~tTimeAdd`
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter Number</th>
|
||||
<th>Category</th>
|
||||
<th>Location</th>
|
||||
<th>Type</th>
|
||||
<th>Field</th>
|
||||
<th>Addional Information</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>0</td>
|
||||
<td colspan="3">instruction</td>
|
||||
<td>color</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>background</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tTime</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>timeAMPM</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tDate</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tMainText</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>6</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast1</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>7</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast2</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>8</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast3</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>9</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast4</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>10</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast1Val</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>11</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast2Val</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>12</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast3Val</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>13</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tForecast4Val</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>14</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>bar</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>15</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tMainTextAlt2</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>16</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tMR</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>17</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>tTimeAdd</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
`notify~heading~text`
|
||||
|
||||
|
||||
402
HMI/code_gen/pages/out.txt
Normal file
402
HMI/code_gen/pages/out.txt
Normal file
@@ -0,0 +1,402 @@
|
||||
|
||||
// data available
|
||||
if(usize>1)
|
||||
{
|
||||
bufferPos=0
|
||||
while(bufferPos<usize)
|
||||
{
|
||||
// check for 0x55 0xBB - Command Init Secuence
|
||||
if(u[bufferPos]==187&&u[bufferPos-1]==85)
|
||||
{
|
||||
//remove garbage at the start of the buffer if there's any to free buffer for command
|
||||
if(u[bufferPos]!=1)
|
||||
{
|
||||
udelete bufferPos-1
|
||||
}
|
||||
//instruction is now aligned with buffer, because we deleted garbage before instrcution
|
||||
//get length after init sequence (check if there are more than to bytes in buffer)
|
||||
if(3<usize)
|
||||
{
|
||||
// check if serial buffer has reached the announced length
|
||||
ucopy payloadLength,2,2,0
|
||||
// we are only checking payload length so we have to skip first 3 bytes (init+payload length) (-1 because of < instead of <=)
|
||||
payloadLength+=3
|
||||
// payload length does also not contain crc, so we are adding another 2 bytes for crc
|
||||
payloadLength+=2
|
||||
if(payloadLength<usize)
|
||||
{
|
||||
// calculate crc
|
||||
crcrest 1,0xFFFF
|
||||
// u[2] contains payload legth at 3rd pos in buffer, we are calculating crc from 3rd pos with number of bytes from payload length
|
||||
//crcputu 3,u[2]
|
||||
// u[2] cotnains payload length, we are calculating a crc over the whole message, so we have to add 3 to the length from u[2]
|
||||
crcputu 0,payloadLength-1
|
||||
// get recived crc to be able to compare it
|
||||
ucopy recvCrc,payloadLength-1,2,0
|
||||
// compare crc with recived value
|
||||
if(crcval==recvCrc)
|
||||
{
|
||||
// crc is okay
|
||||
// here is the location where acual code should be
|
||||
// write command to variable strCommand
|
||||
ucopy strCommand.txt,4,payloadLength-5,0
|
||||
// write instruction to tInstuction (debug output, but used as variable here, ui elements will be disabled by default)
|
||||
spstr strCommand.txt,tInstruction.txt,"~",0
|
||||
|
||||
if(tInstruction.txt=="wake")
|
||||
{
|
||||
click tc0,1
|
||||
}
|
||||
if(tInstruction.txt=="dimmode")
|
||||
{
|
||||
// get value
|
||||
spstr strCommand.txt,tTmp.txt,"~",1
|
||||
covx tTmp.txt,dimValue,0,0
|
||||
dim=dimValue
|
||||
// get value normal
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,dimValueNormal,0,0
|
||||
// get background color
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,defaultBcoColor,0,0
|
||||
}
|
||||
// get font color
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,defaultFontColor,0,0
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="time")
|
||||
{
|
||||
click m0,1
|
||||
//get set time to global variable
|
||||
spstr strCommand.txt,pageIcons.vaTime.txt,"~",1
|
||||
spstr pageIcons.vaTime.txt,tTime.txt,"?",0
|
||||
spstr pageIcons.vaTime.txt,tAMPM.txt,"?",1
|
||||
if(tAMPM.txt=="")
|
||||
{
|
||||
vis tAMPM,0
|
||||
}
|
||||
spstr strCommand.txt,tTimeAdd.txt,"~",2
|
||||
ref tIcon1
|
||||
ref tIcon2
|
||||
}
|
||||
if(tInstruction.txt=="date")
|
||||
{
|
||||
//get set date to global variable
|
||||
spstr strCommand.txt,pageIcons.vaDate.txt,"~",1
|
||||
tDate.txt=pageIcons.vaDate.txt
|
||||
}
|
||||
if(tInstruction.txt=="statusUpdate")
|
||||
{
|
||||
//statusIcon1
|
||||
spstr strCommand.txt,tIcon1.txt,"~",1
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,tIcon1.pco,0,0
|
||||
//statusIcon2
|
||||
spstr strCommand.txt,tIcon2.txt,"~",3
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
covx tTmp.txt,tIcon2.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",5
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
tIcon1.font=3
|
||||
}
|
||||
spstr strCommand.txt,tTmp.txt,"~",6
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
tIcon2.font=3
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="weatherUpdate"&&tNotifyHead.txt==""&&tNotifyText.txt=="")
|
||||
{
|
||||
vis tMainIcon,1
|
||||
vis tMainIconAlt,0
|
||||
vis tMainText,1
|
||||
vis tMainTextAlt,0
|
||||
vis tMainTextAlt2,0
|
||||
vis tMainIconAlt2,0
|
||||
|
||||
|
||||
//tMainIcon
|
||||
spstr strCommand.txt,tMainIcon.txt,"~",3
|
||||
tMainIconAlt.txt=tMainIcon.txt
|
||||
//tMainIcon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
covx tTmp.txt,tMainIcon.pco,0,0
|
||||
tMainIconAlt.pco=tMainIcon.pco
|
||||
//tMainText
|
||||
spstr strCommand.txt,tMainText.txt,"~",6
|
||||
tMainTextAlt.txt=tMainText.txt
|
||||
|
||||
//tForecast1
|
||||
spstr strCommand.txt,tForecast1.txt,"~",11
|
||||
//tF1Icon
|
||||
spstr strCommand.txt,tF1Icon.txt,"~",9
|
||||
//tF1Icon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",10
|
||||
covx tTmp.txt,tF1Icon.pco,0,0
|
||||
//tForecast1Val
|
||||
spstr strCommand.txt,tForecast1Val.txt,"~",12
|
||||
|
||||
|
||||
//tForecast2
|
||||
spstr strCommand.txt,tForecast2.txt,"~",17
|
||||
//tF2Icon
|
||||
spstr strCommand.txt,tF2Icon.txt,"~",15
|
||||
//tF2Icon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",16
|
||||
covx tTmp.txt,tF2Icon.pco,0,0
|
||||
//tForecast2Val
|
||||
spstr strCommand.txt,tForecast2Val.txt,"~",18
|
||||
|
||||
|
||||
//tForecast3
|
||||
spstr strCommand.txt,tForecast3.txt,"~",23
|
||||
//tF3Icon
|
||||
spstr strCommand.txt,tF3Icon.txt,"~",21
|
||||
//tF3Icon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",22
|
||||
covx tTmp.txt,tF3Icon.pco,0,0
|
||||
//tForecast3Val
|
||||
spstr strCommand.txt,tForecast3Val.txt,"~",24
|
||||
|
||||
|
||||
//tForecast4
|
||||
spstr strCommand.txt,tForecast4.txt,"~",29
|
||||
//tF4Icon
|
||||
spstr strCommand.txt,tF4Icon.txt,"~",27
|
||||
//tF4Icon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",28
|
||||
covx tTmp.txt,tF4Icon.pco,0,0
|
||||
//tForecast4Val
|
||||
spstr strCommand.txt,tForecast4Val.txt,"~",30
|
||||
|
||||
|
||||
//alternative layout
|
||||
//tMainTextAlt2
|
||||
spstr strCommand.txt,tMainTextAlt2.txt,"~",36
|
||||
//tMainIconAlt2
|
||||
spstr strCommand.txt,tMainIconAlt2.txt,"~",33
|
||||
|
||||
//tMainIconAlt2 Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",34
|
||||
covx tTmp.txt,tMainIconAlt2.pco,0,0
|
||||
|
||||
if(tMainTextAlt2.txt!=""&&p0.w!=320)
|
||||
{
|
||||
//value for tMRIcon, activate alternative layout
|
||||
vis tMainIcon,0
|
||||
vis tMainText,0
|
||||
vis tMainTextAlt,1
|
||||
vis tMainIconAlt,1
|
||||
vis tMainTextAlt2,1
|
||||
vis tMainIconAlt2,1
|
||||
vis tForecast1,0
|
||||
vis tF1Icon,0
|
||||
vis tForecast1Val,0
|
||||
//move forecast values to the right
|
||||
tForecast4.txt=tForecast3.txt
|
||||
tForecast3.txt=tForecast2.txt
|
||||
tForecast2.txt=tForecast1.txt
|
||||
tForecast4Val.txt=tForecast3Val.txt
|
||||
tForecast3Val.txt=tForecast2Val.txt
|
||||
tForecast2Val.txt=tForecast1Val.txt
|
||||
tF4Icon.txt=tF3Icon.txt
|
||||
tF3Icon.txt=tF2Icon.txt
|
||||
tF2Icon.txt=tF1Icon.txt
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="color"&&tNotifyHead.txt==""&&tNotifyText.txt=="")
|
||||
{
|
||||
spstr strCommand.txt,tTmp.txt,"~",1
|
||||
covx tTmp.txt,tTime.bco,0,0
|
||||
if(tTime.bco!=screensaver.bco)
|
||||
{
|
||||
screensaver.bco=tTime.bco
|
||||
tAMPM.bco=tTime.bco
|
||||
tDate.bco=tTime.bco
|
||||
tMainIcon.bco=tTime.bco
|
||||
tMainText.bco=tTime.bco
|
||||
tMainIconAlt.bco=tTime.bco
|
||||
tMainTextAlt.bco=tTime.bco
|
||||
tMainTextAlt2.bco=tTime.bco
|
||||
tMainIconAlt2.bco=tTime.bco
|
||||
tIcon1.bco=tTime.bco
|
||||
tIcon2.bco=tTime.bco
|
||||
tForecast1.bco=tTime.bco
|
||||
tForecast1Val.bco=tTime.bco
|
||||
tF1Icon.bco=tTime.bco
|
||||
tForecast2.bco=tTime.bco
|
||||
tForecast2Val.bco=tTime.bco
|
||||
tF2Icon.bco=tTime.bco
|
||||
tForecast3.bco=tTime.bco
|
||||
tForecast3Val.bco=tTime.bco
|
||||
tF3Icon.bco=tTime.bco
|
||||
tForecast4.bco=tTime.bco
|
||||
tForecast4Val.bco=tTime.bco
|
||||
tF4Icon.bco=tTime.bco
|
||||
tTimeAdd.bco=tTime.bco
|
||||
}
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,tTime.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
covx tTmp.txt,tAMPM.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
covx tTmp.txt,tDate.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",5
|
||||
covx tTmp.txt,tMainText.pco,0,0
|
||||
tMainTextAlt.pco=tMainText.pco
|
||||
spstr strCommand.txt,tTmp.txt,"~",6
|
||||
covx tTmp.txt,tForecast1.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",7
|
||||
covx tTmp.txt,tForecast2.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",8
|
||||
covx tTmp.txt,tForecast3.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",9
|
||||
covx tTmp.txt,tForecast4.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",10
|
||||
covx tTmp.txt,tForecast1Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",11
|
||||
covx tTmp.txt,tForecast2Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",12
|
||||
covx tTmp.txt,tForecast3Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",13
|
||||
covx tTmp.txt,tForecast4Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",14
|
||||
covx tTmp.txt,t10.bco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",15
|
||||
covx tTmp.txt,tMainTextAlt2.pco,0,0
|
||||
//spstr strCommand.txt,tTmp.txt,"~",16
|
||||
//covx tTmp.txt,tMR.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",17
|
||||
covx tTmp.txt,tTimeAdd.pco,0,0
|
||||
if(tMainTextAlt2.txt!=""&&p0.w!=320)
|
||||
{
|
||||
tForecast4Val.pco=tForecast3Val.pco
|
||||
tForecast3Val.pco=tForecast2Val.pco
|
||||
tForecast2Val.pco=tForecast1Val.pco
|
||||
tForecast4.pco=tForecast3.pco
|
||||
tForecast3.pco=tForecast2.pco
|
||||
tForecast2.pco=tForecast1.pco
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="notify")
|
||||
{
|
||||
spstr strCommand.txt,tNotifyHead.txt,"~",1
|
||||
spstr strCommand.txt,tNotifyText.txt,"~",2
|
||||
if(tNotifyHead.txt!=""||tNotifyText.txt!="")
|
||||
{
|
||||
vis tNotifyHead,1
|
||||
vis tNotifyText,1
|
||||
}else
|
||||
{
|
||||
vis tNotifyHead,0
|
||||
vis tNotifyText,0
|
||||
}
|
||||
tNotifyHead.bco=tTime.bco
|
||||
tNotifyText.bco=tTime.bco
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,tNotifyHead.pco,0,0
|
||||
}
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,tNotifyText.pco,0,0
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(tInstruction.txt=="pageType")
|
||||
{
|
||||
dim=100
|
||||
//command format pageType,specialPageName
|
||||
//write name of speical page to tId
|
||||
spstr strCommand.txt,tId.txt,"~",1
|
||||
//save second arg if there's one
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
//save third arg if there's one
|
||||
spstr strCommand.txt,pageIcons.tTmp2.txt,"~",3
|
||||
spstr strCommand.txt,pageIcons.tTmp3.txt,"~",4
|
||||
//we are going to exit this page with this command, so we have to clear the buffer, so we are not getting into a stupid loop ...
|
||||
udelete payloadLength-1
|
||||
bufferPos=0
|
||||
if(tId.txt=="pageStartup")
|
||||
{
|
||||
page pageStartup
|
||||
}
|
||||
if(tId.txt=="screensaver")
|
||||
{
|
||||
page screensaver
|
||||
}
|
||||
if(tId.txt=="cardEntities")
|
||||
{
|
||||
page cardEntities
|
||||
}
|
||||
if(tId.txt=="cardGrid")
|
||||
{
|
||||
page cardGrid
|
||||
}
|
||||
if(tId.txt=="popupLight")
|
||||
{
|
||||
pageIcons.tTmp1.txt=tTmp.txt
|
||||
page popupLight
|
||||
}
|
||||
if(tId.txt=="popupShutter")
|
||||
{
|
||||
pageIcons.tTmp1.txt=tTmp.txt
|
||||
page popupShutter
|
||||
}
|
||||
if(tId.txt=="popupNotify")
|
||||
{
|
||||
page popupNotify
|
||||
}
|
||||
if(tId.txt=="cardThermo")
|
||||
{
|
||||
page cardThermo
|
||||
}
|
||||
if(tId.txt=="cardMedia")
|
||||
{
|
||||
page cardMedia
|
||||
}
|
||||
if(tId.txt=="cardAlarm")
|
||||
{
|
||||
page cardAlarm
|
||||
}
|
||||
if(tId.txt=="cardQR")
|
||||
{
|
||||
page cardQR
|
||||
}
|
||||
if(tId.txt=="cardPower")
|
||||
{
|
||||
page cardPower
|
||||
}
|
||||
if(tId.txt=="cardChart")
|
||||
{
|
||||
page cardChart
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="timeout")
|
||||
{
|
||||
//set timeout to global var
|
||||
spstr strCommand.txt,tTmp.txt,"~",1
|
||||
covx tTmp.txt,sleepTimeout,0,0
|
||||
}
|
||||
// end of user code
|
||||
udelete payloadLength-1
|
||||
bufferPos=0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// next character
|
||||
bufferPos++
|
||||
}
|
||||
}
|
||||
|
||||
313
HMI/code_gen/pages/screensaver.py
Normal file
313
HMI/code_gen/pages/screensaver.py
Normal file
@@ -0,0 +1,313 @@
|
||||
from shared import *
|
||||
head = sharedhead + """
|
||||
if(tInstruction.txt=="wake")
|
||||
{
|
||||
click tc0,1
|
||||
}
|
||||
if(tInstruction.txt=="dimmode")
|
||||
{
|
||||
// get value
|
||||
spstr strCommand.txt,tTmp.txt,"~",1
|
||||
covx tTmp.txt,dimValue,0,0
|
||||
dim=dimValue
|
||||
// get value normal
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,dimValueNormal,0,0
|
||||
// get background color
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,defaultBcoColor,0,0
|
||||
}
|
||||
// get font color
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,defaultFontColor,0,0
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="time")
|
||||
{
|
||||
click m0,1
|
||||
//get set time to global variable
|
||||
spstr strCommand.txt,pageIcons.vaTime.txt,"~",1
|
||||
spstr pageIcons.vaTime.txt,tTime.txt,"?",0
|
||||
spstr pageIcons.vaTime.txt,tAMPM.txt,"?",1
|
||||
if(tAMPM.txt=="")
|
||||
{
|
||||
vis tAMPM,0
|
||||
}
|
||||
spstr strCommand.txt,tTimeAdd.txt,"~",2
|
||||
ref tIcon1
|
||||
ref tIcon2
|
||||
}
|
||||
if(tInstruction.txt=="date")
|
||||
{
|
||||
//get set date to global variable
|
||||
spstr strCommand.txt,pageIcons.vaDate.txt,"~",1
|
||||
tDate.txt=pageIcons.vaDate.txt
|
||||
}
|
||||
if(tInstruction.txt=="statusUpdate")
|
||||
{
|
||||
//statusIcon1
|
||||
spstr strCommand.txt,tIcon1.txt,"~",1
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,tIcon1.pco,0,0
|
||||
//statusIcon2
|
||||
spstr strCommand.txt,tIcon2.txt,"~",3
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
covx tTmp.txt,tIcon2.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",5
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
tIcon1.font=3
|
||||
}
|
||||
spstr strCommand.txt,tTmp.txt,"~",6
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
tIcon2.font=3
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="weatherUpdate"&&tNotifyHead.txt==""&&tNotifyText.txt=="")
|
||||
{
|
||||
vis tMainIcon,1
|
||||
vis tMainIconAlt,0
|
||||
vis tMainText,1
|
||||
vis tMainTextAlt,0
|
||||
vis tMainTextAlt2,0
|
||||
vis tMainIconAlt2,0
|
||||
|
||||
|
||||
//tMainIcon
|
||||
spstr strCommand.txt,tMainIcon.txt,"~",3
|
||||
tMainIconAlt.txt=tMainIcon.txt
|
||||
//tMainIcon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
covx tTmp.txt,tMainIcon.pco,0,0
|
||||
tMainIconAlt.pco=tMainIcon.pco
|
||||
//tMainText
|
||||
spstr strCommand.txt,tMainText.txt,"~",6
|
||||
tMainTextAlt.txt=tMainText.txt
|
||||
"""
|
||||
|
||||
start = 7
|
||||
for i in range(1,5):
|
||||
idxstart = start + (i-1)*6
|
||||
item = f"""
|
||||
//tForecast{i}
|
||||
spstr strCommand.txt,tForecast{i}.txt,"~",{idxstart+4}
|
||||
//tF{i}Icon
|
||||
spstr strCommand.txt,tF{i}Icon.txt,"~",{idxstart+2}
|
||||
//tF{i}Icon Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",{idxstart+3}
|
||||
covx tTmp.txt,tF{i}Icon.pco,0,0
|
||||
//tForecast{i}Val
|
||||
spstr strCommand.txt,tForecast{i}Val.txt,"~",{idxstart+5}
|
||||
|
||||
"""
|
||||
head = head + item
|
||||
|
||||
head = head + """
|
||||
//alternative layout
|
||||
//tMainTextAlt2
|
||||
spstr strCommand.txt,tMainTextAlt2.txt,"~",36
|
||||
//tMainIconAlt2
|
||||
spstr strCommand.txt,tMainIconAlt2.txt,"~",33
|
||||
|
||||
//tMainIconAlt2 Color
|
||||
spstr strCommand.txt,tTmp.txt,"~",34
|
||||
covx tTmp.txt,tMainIconAlt2.pco,0,0
|
||||
|
||||
if(tMainTextAlt2.txt!=""&&p0.w!=320)
|
||||
{
|
||||
//value for tMRIcon, activate alternative layout
|
||||
vis tMainIcon,0
|
||||
vis tMainText,0
|
||||
vis tMainTextAlt,1
|
||||
vis tMainIconAlt,1
|
||||
vis tMainTextAlt2,1
|
||||
vis tMainIconAlt2,1
|
||||
vis tForecast1,0
|
||||
vis tF1Icon,0
|
||||
vis tForecast1Val,0
|
||||
//move forecast values to the right
|
||||
tForecast4.txt=tForecast3.txt
|
||||
tForecast3.txt=tForecast2.txt
|
||||
tForecast2.txt=tForecast1.txt
|
||||
tForecast4Val.txt=tForecast3Val.txt
|
||||
tForecast3Val.txt=tForecast2Val.txt
|
||||
tForecast2Val.txt=tForecast1Val.txt
|
||||
tF4Icon.txt=tF3Icon.txt
|
||||
tF3Icon.txt=tF2Icon.txt
|
||||
tF2Icon.txt=tF1Icon.txt
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="color"&&tNotifyHead.txt==""&&tNotifyText.txt=="")
|
||||
{
|
||||
spstr strCommand.txt,tTmp.txt,"~",1
|
||||
covx tTmp.txt,tTime.bco,0,0
|
||||
if(tTime.bco!=screensaver.bco)
|
||||
{
|
||||
screensaver.bco=tTime.bco
|
||||
tAMPM.bco=tTime.bco
|
||||
tDate.bco=tTime.bco
|
||||
tMainIcon.bco=tTime.bco
|
||||
tMainText.bco=tTime.bco
|
||||
tMainIconAlt.bco=tTime.bco
|
||||
tMainTextAlt.bco=tTime.bco
|
||||
tMainTextAlt2.bco=tTime.bco
|
||||
tMainIconAlt2.bco=tTime.bco
|
||||
tIcon1.bco=tTime.bco
|
||||
tIcon2.bco=tTime.bco
|
||||
tForecast1.bco=tTime.bco
|
||||
tForecast1Val.bco=tTime.bco
|
||||
tF1Icon.bco=tTime.bco
|
||||
tForecast2.bco=tTime.bco
|
||||
tForecast2Val.bco=tTime.bco
|
||||
tF2Icon.bco=tTime.bco
|
||||
tForecast3.bco=tTime.bco
|
||||
tForecast3Val.bco=tTime.bco
|
||||
tF3Icon.bco=tTime.bco
|
||||
tForecast4.bco=tTime.bco
|
||||
tForecast4Val.bco=tTime.bco
|
||||
tF4Icon.bco=tTime.bco
|
||||
tTimeAdd.bco=tTime.bco
|
||||
}
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,tTime.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
covx tTmp.txt,tAMPM.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
covx tTmp.txt,tDate.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",5
|
||||
covx tTmp.txt,tMainText.pco,0,0
|
||||
tMainTextAlt.pco=tMainText.pco
|
||||
spstr strCommand.txt,tTmp.txt,"~",6
|
||||
covx tTmp.txt,tForecast1.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",7
|
||||
covx tTmp.txt,tForecast2.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",8
|
||||
covx tTmp.txt,tForecast3.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",9
|
||||
covx tTmp.txt,tForecast4.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",10
|
||||
covx tTmp.txt,tForecast1Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",11
|
||||
covx tTmp.txt,tForecast2Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",12
|
||||
covx tTmp.txt,tForecast3Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",13
|
||||
covx tTmp.txt,tForecast4Val.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",14
|
||||
covx tTmp.txt,t10.bco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",15
|
||||
covx tTmp.txt,tMainTextAlt2.pco,0,0
|
||||
//spstr strCommand.txt,tTmp.txt,"~",16
|
||||
//covx tTmp.txt,tMR.pco,0,0
|
||||
spstr strCommand.txt,tTmp.txt,"~",17
|
||||
covx tTmp.txt,tTimeAdd.pco,0,0
|
||||
if(tMainTextAlt2.txt!=""&&p0.w!=320)
|
||||
{
|
||||
tForecast4Val.pco=tForecast3Val.pco
|
||||
tForecast3Val.pco=tForecast2Val.pco
|
||||
tForecast2Val.pco=tForecast1Val.pco
|
||||
tForecast4.pco=tForecast3.pco
|
||||
tForecast3.pco=tForecast2.pco
|
||||
tForecast2.pco=tForecast1.pco
|
||||
}
|
||||
}
|
||||
if(tInstruction.txt=="notify")
|
||||
{
|
||||
spstr strCommand.txt,tNotifyHead.txt,"~",1
|
||||
spstr strCommand.txt,tNotifyText.txt,"~",2
|
||||
if(tNotifyHead.txt!=""||tNotifyText.txt!="")
|
||||
{
|
||||
vis tNotifyHead,1
|
||||
vis tNotifyText,1
|
||||
}else
|
||||
{
|
||||
vis tNotifyHead,0
|
||||
vis tNotifyText,0
|
||||
}
|
||||
tNotifyHead.bco=tTime.bco
|
||||
tNotifyText.bco=tTime.bco
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,tNotifyHead.pco,0,0
|
||||
}
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,tNotifyText.pco,0,0
|
||||
}
|
||||
"""
|
||||
|
||||
print(head)
|
||||
|
||||
|
||||
#start = 23
|
||||
#for i in range(1,7):
|
||||
# idxstart = start + (i-1)*6
|
||||
# item = f"""
|
||||
# // get Type
|
||||
# spstr strCommand.txt,type{i}.txt,"~",{idxstart}
|
||||
# // get internal name
|
||||
# spstr strCommand.txt,entn{i}.txt,"~",{idxstart+1}
|
||||
# if(type{i}.txt=="delete"||type{i}.txt=="")
|
||||
# {{
|
||||
# vis tEntity{i},0
|
||||
# vis bEntity{i},0
|
||||
# }}else
|
||||
# {{
|
||||
# // change icon
|
||||
# spstr strCommand.txt,bEntity{i}.txt,"~",{idxstart+2}
|
||||
# vis bEntity{i},1
|
||||
# // change icon color
|
||||
# spstr strCommand.txt,tTmp.txt,"~",{idxstart+3}
|
||||
# covx tTmp.txt,sys0,0,0
|
||||
# bEntity{i}.pco=sys0
|
||||
# // set name
|
||||
# spstr strCommand.txt,tEntity{i}.txt,"~",{idxstart+4}
|
||||
# vis tEntity{i},1
|
||||
# }}
|
||||
#"""
|
||||
# print(item)
|
||||
foot = """
|
||||
}
|
||||
""" + sharedfoot.replace("sleepValue=0", "dim=100").replace("""
|
||||
if(tInstruction.txt=="time")
|
||||
{
|
||||
// get set time to global variable
|
||||
spstr strCommand.txt,pageIcons.vaTime.txt,"~",1
|
||||
}
|
||||
if(tInstruction.txt=="date")
|
||||
{
|
||||
// get set date to global variable
|
||||
spstr strCommand.txt,pageIcons.vaDate.txt,"~",1
|
||||
}
|
||||
if(tInstruction.txt=="dimmode")
|
||||
{
|
||||
// get value
|
||||
spstr strCommand.txt,tTmp.txt,"~",1
|
||||
covx tTmp.txt,dimValue,0,0
|
||||
// get value normal
|
||||
spstr strCommand.txt,tTmp.txt,"~",2
|
||||
covx tTmp.txt,dimValueNormal,0,0
|
||||
dim=dimValueNormal
|
||||
// get background color
|
||||
spstr strCommand.txt,tTmp.txt,"~",3
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,defaultBcoColor,0,0
|
||||
}
|
||||
// get font color
|
||||
spstr strCommand.txt,tTmp.txt,"~",4
|
||||
if(tTmp.txt!="")
|
||||
{
|
||||
covx tTmp.txt,defaultFontColor,0,0
|
||||
}
|
||||
}""","")
|
||||
print(foot)
|
||||
|
||||
|
||||
BIN
HMI/nspanel.HMI
BIN
HMI/nspanel.HMI
Binary file not shown.
BIN
HMI/nspanel.tft
BIN
HMI/nspanel.tft
Binary file not shown.
@@ -23,6 +23,7 @@ class Entity(object):
|
||||
self.condStateNot = entity_input_config.get("state_not")
|
||||
self.condTemplate = entity_input_config.get("state_template")
|
||||
self.assumedState = entity_input_config.get("assumed_state", False)
|
||||
self.stype = entity_input_config.get("type")
|
||||
self.data = entity_input_config.get("data", {})
|
||||
self.entity_input_config = entity_input_config
|
||||
|
||||
@@ -61,7 +62,7 @@ class Card(object):
|
||||
entityIds.append(e.status)
|
||||
|
||||
# additional keys to check
|
||||
add_ent_keys = ['weatherOverrideForecast1', 'weatherOverrideForecast2', 'weatherOverrideForecast3', 'weatherOverrideForecast4', 'statusIcon1', 'statusIcon2', 'alarmControl']
|
||||
add_ent_keys = ['statusIcon1', 'statusIcon2', 'alarmControl']
|
||||
for ent_key in add_ent_keys:
|
||||
val = self.raw_config.get(ent_key)
|
||||
if val is not None:
|
||||
|
||||
@@ -24,7 +24,7 @@ class LuiPagesGen(object):
|
||||
self._locale = config.get("locale")
|
||||
self._send_mqtt_msg = send_mqtt_msg
|
||||
|
||||
def get_entity_color(self, entity, ha_type=None, overwrite=None):
|
||||
def get_entity_color(self, entity, ha_type=None, stateOverwrite=None, overwrite=None):
|
||||
if overwrite is not None:
|
||||
if type(overwrite) in [str, list]:
|
||||
return rgb_dec565(overwrite)
|
||||
@@ -37,33 +37,60 @@ class LuiPagesGen(object):
|
||||
default_color = rgb_dec565([68, 115, 158])
|
||||
return default_color
|
||||
else:
|
||||
state = entity.state
|
||||
if stateOverwrite is not None:
|
||||
state = stateOverwrite
|
||||
attr = entity.attributes
|
||||
default_color_on = rgb_dec565([253, 216, 53])
|
||||
default_color_off = rgb_dec565([68, 115, 158])
|
||||
icon_color = default_color_on if entity.state in ["on", "unlocked", "above_horizon", "home", "active"] else default_color_off
|
||||
icon_color = default_color_on if state in ["on", "unlocked", "above_horizon", "home", "active"] else default_color_off
|
||||
|
||||
if ha_type == "alarm_control_panel":
|
||||
if entity.state == "disarmed":
|
||||
if state == "disarmed":
|
||||
icon_color = rgb_dec565([13,160,53])
|
||||
if entity.state == "arming":
|
||||
if state == "arming":
|
||||
icon_color = rgb_dec565([244,180,0])
|
||||
if entity.state in ["armed_home", "armed_away", "armed_night", "armed_vacation", "pending", "triggered"]:
|
||||
if state in ["armed_home", "armed_away", "armed_night", "armed_vacation", "pending", "triggered"]:
|
||||
icon_color = rgb_dec565([223,76,30])
|
||||
|
||||
if ha_type == "climate":
|
||||
if entity.state in ["auto", "heat_cool"]:
|
||||
if state in ["auto", "heat_cool"]:
|
||||
icon_color = 1024
|
||||
if entity.state == "heat":
|
||||
if state == "heat":
|
||||
icon_color = 64512
|
||||
if entity.state == "off":
|
||||
if state == "off":
|
||||
icon_color = 35921
|
||||
if entity.state == "cool":
|
||||
if state == "cool":
|
||||
icon_color = 11487
|
||||
if entity.state == "dry":
|
||||
if state == "dry":
|
||||
icon_color = 60897
|
||||
if entity.state == "fan_only":
|
||||
if state == "fan_only":
|
||||
icon_color = 35921
|
||||
|
||||
if ha_type == "weather":
|
||||
if state in ["clear-night", "partlycloudy", "windy", "windy-variant"]:
|
||||
icon_color = 35957 #50% grey
|
||||
if state == "cloudy":
|
||||
icon_color = 31728 #grey-blue
|
||||
if state == "exceptional":
|
||||
icon_color = 63488 #red
|
||||
if state == "fog":
|
||||
icon_color = 21130 #75% grey
|
||||
if state in ["hail", "snowy"]:
|
||||
icon_color = 65535 #white
|
||||
if state == "lightning":
|
||||
icon_color = 65120 #golden-yellow
|
||||
if state == "lightning-rainy":
|
||||
icon_color = 50400 #dark-golden-yellow
|
||||
if state == "pouring":
|
||||
icon_color = 249 #blue
|
||||
if state == "rainy":
|
||||
icon_color = 33759 #light-blue
|
||||
if state == "snowy-rainy":
|
||||
icon_color = 44479 #light-blue-grey
|
||||
if state == "sunny":
|
||||
icon_color = 63469 #bright-yellow
|
||||
|
||||
if "rgb_color" in attr:
|
||||
color = attr.rgb_color
|
||||
if "brightness" in attr:
|
||||
@@ -97,100 +124,19 @@ class LuiPagesGen(object):
|
||||
self._send_mqtt_msg(f"pageType~{target_page}")
|
||||
|
||||
def update_screensaver_weather(self, theme):
|
||||
global babel_spec
|
||||
we_name = self._config._config_screensaver.entity.entityId
|
||||
unit = self._config._config_screensaver.raw_config.get("weatherUnit", "celsius")
|
||||
state = {}
|
||||
|
||||
if apis.ha_api.entity_exists(we_name):
|
||||
we = apis.ha_api.get_entity(we_name)
|
||||
else:
|
||||
apis.ha_api.error(f"Skipping Weather Update, entity {we_name} not found")
|
||||
return
|
||||
entities = self._config._config_screensaver.entities
|
||||
|
||||
icon_cur = get_icon_ha(we_name)
|
||||
state["tMainIcon"] = we.state
|
||||
text_cur = convert_temperature(we.attributes.temperature, unit)
|
||||
# default screensaver based on configured entity
|
||||
if len(entities) == 0:
|
||||
entities.append(self._config._config_screensaver.entity)
|
||||
for i in range(0,4):
|
||||
entities.append(Entity({'entity': f'{self._config._config_screensaver.entity.entityId}','type': i}))
|
||||
|
||||
if self._config._config_screensaver.raw_config.get("alternativeLayout", False):
|
||||
text_cur = f"{get_icon_id('thermometer')}{text_cur}"
|
||||
item_str = ""
|
||||
for item in entities:
|
||||
item_str += self.generate_entities_item(item, "cardGrid")
|
||||
|
||||
forecastSkip = self._config._config_screensaver.raw_config.get(f"forecastSkip")+1
|
||||
# check if the difference between the first 2 forecast items is less than 24h
|
||||
difference = (dp.parse(we.attributes.forecast[forecastSkip]['datetime']) - dp.parse(we.attributes.forecast[0]['datetime']))
|
||||
total_seconds = difference.total_seconds()
|
||||
same_day = total_seconds < 86400
|
||||
weather_res = ""
|
||||
for i in range(1,5):
|
||||
wOF = self._config._config_screensaver.raw_config.get(f"weatherOverrideForecast{i}")
|
||||
if wOF is None:
|
||||
fid = (i-1)*forecastSkip
|
||||
if len(we.attributes.forecast) >= fid:
|
||||
up = we.attributes.forecast[fid]['datetime']
|
||||
up = dp.parse(up).astimezone()
|
||||
if babel_spec is not None:
|
||||
if same_day:
|
||||
up = babel.dates.format_time(up, "H:mm", locale=self._locale)
|
||||
else:
|
||||
up = babel.dates.format_date(up, "E", locale=self._locale)
|
||||
else:
|
||||
if same_day:
|
||||
up = up.strftime('%H:%M')
|
||||
else:
|
||||
up = up.strftime('%a')
|
||||
icon = get_icon_ha(we_name, stateOverwrite=we.attributes.forecast[fid]['condition'])
|
||||
if i == 1:
|
||||
state["tF1Icon"] = we.attributes.forecast[fid]['condition']
|
||||
elif i == 2:
|
||||
state["tF2Icon"] = we.attributes.forecast[fid]['condition']
|
||||
elif i == 3:
|
||||
state["tF3Icon"] = we.attributes.forecast[fid]['condition']
|
||||
elif i == 4:
|
||||
state["tF4Icon"] = we.attributes.forecast[fid]['condition']
|
||||
down = convert_temperature(we.attributes.forecast[fid]['temperature'], unit)
|
||||
else:
|
||||
up = ""
|
||||
icon = ""
|
||||
down = ""
|
||||
else:
|
||||
apis.ha_api.log(f"Forecast {i} is overriden with {wOF}")
|
||||
icon = wOF.get("icon")
|
||||
name = wOF.get("name")
|
||||
entity = apis.ha_api.get_entity(wOF.get("entity"))
|
||||
up = name if name is not None else entity.attributes.friendly_name
|
||||
icon = get_icon_ha(wOF.get("entity"), overwrite=icon)
|
||||
if "color" in wOF:
|
||||
if theme is None:
|
||||
theme = {}
|
||||
color = wOF.get("color")
|
||||
if type(color) is dict:
|
||||
for overwrite_state, overwrite_val in color.items():
|
||||
if overwrite_state == entity.state:
|
||||
color = overwrite_val
|
||||
if i == 1:
|
||||
theme["tF1Icon"] = color
|
||||
elif i == 2:
|
||||
theme["tF2Icon"] = color
|
||||
elif i == 3:
|
||||
theme["tF3Icon"] = color
|
||||
elif i == 4:
|
||||
theme["tF4Icon"] = color
|
||||
|
||||
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
|
||||
down = f"{entity.state} {unit_of_measurement}"
|
||||
weather_res+=f"~{up}~{icon}~{down}"
|
||||
|
||||
altLayout = "~"
|
||||
if self._config._config_screensaver.raw_config.get("alternativeLayout", False):
|
||||
indoorTemp = self._config._config_screensaver.raw_config.get("indoorTemp")
|
||||
if indoorTemp is not None and apis.ha_api.entity_exists(indoorTemp.get("entity","")):
|
||||
entity = apis.ha_api.get_entity(indoorTemp.get("entity"))
|
||||
icon = get_icon_ha(indoorTemp.get("entity"), overwrite=indoorTemp.get("icon"))
|
||||
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
|
||||
altLayout = f"~{icon}{entity.state}{unit_of_measurement}"
|
||||
else:
|
||||
altLayout = f"~{get_icon_id('water-percent')}{we.attributes.humidity} %"
|
||||
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}")
|
||||
self._send_mqtt_msg(f"weatherUpdate{item_str}")
|
||||
|
||||
def update_status_icons(self):
|
||||
status_res = ""
|
||||
@@ -397,6 +343,21 @@ class LuiPagesGen(object):
|
||||
elif entityType == "timer":
|
||||
entityTypePanel = "timer"
|
||||
value = get_translation(self._locale, f"backend.component.timer.state._.{entity.state}")
|
||||
elif entityType == "weather":
|
||||
entityTypePanel = "text"
|
||||
unit = get_attr_safe(entity, "temperature_unit", "")
|
||||
if type(item.stype) == int and len(entity.attributes.forecast) >= item.stype:
|
||||
fdate = dp.parse(entity.attributes.forecast[item.stype]['datetime']).astimezone()
|
||||
global babel_spec
|
||||
if babel_spec is not None:
|
||||
name = babel.dates.format_date(fdate, "E", locale=self._locale)
|
||||
else:
|
||||
name = fdate.strftime('%a')
|
||||
icon_id = get_icon_ha(entityId, stateOverwrite=entity.attributes.forecast[item.stype]['condition'])
|
||||
value = f'{entity.attributes.forecast[item.stype].get("temperature", "")}{unit}'
|
||||
color = self.get_entity_color(entity, ha_type=entityType, stateOverwrite=entity.attributes.forecast[item.stype]['condition'], overwrite=colorOverride)
|
||||
else:
|
||||
value = f'{get_attr_safe(entity, "temperature", "")}{unit}'
|
||||
else:
|
||||
name = "unsupported"
|
||||
return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}"
|
||||
|
||||
@@ -27,25 +27,6 @@ default_screensaver_color_mapping = {
|
||||
"tTimeAdd": "65535"
|
||||
}
|
||||
|
||||
default_weather_icon_color_mapping = {
|
||||
#"item-per HA" "color in decimal RGB 565 (0-65535)"
|
||||
"clear-night": "35957", #50% grey
|
||||
"cloudy": "31728", #grey-blue
|
||||
"exceptional": "63488", #red
|
||||
"fog": "21130", #75% grey
|
||||
"hail": "65535", #white
|
||||
"lightning": "65120", #golden-yellow
|
||||
"lightning-rainy": "50400", #dark-golden-yellow
|
||||
"partlycloudy": "35957", #50% grey
|
||||
"pouring": "249", #blue
|
||||
"rainy": "33759", #light-blue
|
||||
"snowy": "65535", #white
|
||||
"snowy-rainy": "44479", #light-blue-grey
|
||||
"sunny": "63469", #bright-yellow
|
||||
"windy": "35957", #50% grey
|
||||
"windy-variant": "35957" #50% grey
|
||||
}
|
||||
|
||||
def get_screensaver_color_output(theme, state=None):
|
||||
color_output = "color"
|
||||
for key in default_screensaver_color_mapping:
|
||||
@@ -66,8 +47,6 @@ def map_color(key, theme, state=None):
|
||||
def map_weather_icon_color(key, theme, state):
|
||||
if key in state and state[key] in theme:
|
||||
config_color = rgb_dec565(theme[state[key]])
|
||||
elif key in state and state[key] in default_weather_icon_color_mapping:
|
||||
config_color = default_weather_icon_color_mapping[state[key]]
|
||||
else:
|
||||
config_color = "65535"
|
||||
return config_color
|
||||
|
||||
Reference in New Issue
Block a user