├── .github └── ISSUE_TEMPLATE │ ├── config.yml │ ├── richiesta-nuova-funzionalità.md │ └── segnala-un-bug.md ├── LICENSE ├── README.md ├── packages └── pc.yaml ├── pc.lovelace └── python_scripts ├── update_entities.py └── update_entities_new.py /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/richiesta-nuova-funzionalità.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Richiesta nuova funzionalità 3 | about: Suggerisci un'idea da implementare nel progetto 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Descrivi il problema che vorresti risolvere con una nuova funzionalità** 11 | Esponi quale problema hai, in modo chiaro e conciso, che con una nuova funzionalità potresti risolvere. Ad esempio: "Mi accade questa cosa, ...." 12 | 13 | **La tua soluzione** 14 | Spiega che cosa vorresti che accadesse quando si verifica il problema spiegato sopra. 15 | 16 | **Alternative** 17 | Se hai pensato a modalità alternative di funzionamento o workaround, prova a descriverle qui. 18 | 19 | **Informazioni aggiuntive** 20 | Aggiungi qualunque altra informazione o screenshot che ritieni possano essere utili a spiegare la tua richiesta. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/segnala-un-bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Segnala un bug 3 | about: Crea una segnalazione per aiutarci ad aiutarti 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Informazioni sul sistema** 11 | _- Versione Home Assistant_ 12 | _- Tipo installazione (core, VENV, container, ecc...)_ 13 | _- Versione package_ 14 | _- HAI ATTIVATO I LOG?_ 15 | 16 | **Descrivi il problema** 17 | _Descrizione sommaria dl problema. **E ATTIVA I LOG**!_ 18 | 19 | **Passi per riprodurre il problema** 20 | Indicazioni su come riprodurre le condizioni che hanno portato al bug: 21 | _1. Vai qui '...'_ 22 | _2. Clicca la '....'_ 23 | _3. Scrolla giù '....'_ 24 | _4. Riavvia di su '...'_ 25 | _etc...__ 26 | _**PERÒ ATTIVA I LOG!**_ 27 | 28 | **Cosa ti aspettavi** 29 | Descrizione breve del comportamento che ti aspettavi 30 | **DOPO AVER ATTIVATO I LOG!** 31 | 32 | **Screenshots** 33 | _Se applicabile alla tua problematica, posta uno screeshot._ 34 | **E SE ANCORA NON L'HAI FATTO, ATTIVA I LOG!** 35 | 36 | **Log:** 37 | _I log sono importanti per la diagnosi di un problema. [Attivali!](https://github.com/andbad/HA_PowerControl#debug) e postali qui._ 38 | 39 | **Informazioni aggiuntive** 40 | _Altre informazioni che potrebbero sembrarti utili._ 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Buy Me A Coffee 2 | ![GitHub Release](https://img.shields.io/github/v/release/andbad/HA_PowerControl) 3 | ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/andbad/HA_PowerControl) 4 | 5 | # HA_PowerControl 6 | Il package seguente, unito allo script python "update_entities.py" mira ad evitare il distacco del contatore a causa della troppa potenza assorbita dai vari elettrodomestici (carichi). 7 | Requisito hardware fondamentale è la presenza di switch sui carichi da controllare e di un sensore che misura la potenza dei singoli carichi. 8 | Ho utilizzato dispositivi Shelly 1PM e Shelly Plug S, perfetti per lo scopo. 9 | E' consigliato, ma non tassativo, l'utilizzo di un sensore che monitori il consumo complessivo dell'impianto (es. Shelly EM o un ESP8266+PZEM). 10 | La logica prevede la configurazione di due soglie di potenza massima e due tempistiche di intervento (che rispecchiano la logica di funzionamento dei contatori di energia elettrica utilizzati in Italia): 11 | - se l'assorbimento complessivo supera il valore di "Potenza Massima Ritardato", il pacchetto attende il valore in minuti di "Minuti distacco ritardato", dopo i quali inizia a scollegare i carichi; 12 | - se l'assorbimento complessivo supera invece il valor di "Potenza massima immediato", attende un numero di secondi impostato in "Secondi distacco immediato" e poi inizia il distacco. 13 | 14 | Lo scollegamento dei carichi che stanno assorbendo energia parte da quelli a minore priorità (Carico 20) fino a quelli a maggiore priorità (Carico 1), fino a che l'utilizzo complessivo della potenza rientri nel limite prefissato. Se un carico non sta assorbendo, non viene distaccato. 15 | Lo script tiene memoria dell'assorbimento del carico prima del distacco e lo ricollega solo quando la disponibilità di potenza è sufficiente a non causare un nuovo distacco, in ordine di priorità inverso (da Carico 1 a Carico 20). La riattivazione automatica può essere disabilitata per ogni singolo carico. 16 | La configurazione è interamente tramite interfaccia grafica, tranne il gruppo di notifica (notify.tutti) che va impostato manualmente. 17 | 18 | ## Installazione 19 | - Copiare il file "packages/pc.yaml" nella directory "packages" 20 | - Copiare i file "python_scripts/update_entities.py" e "python_scripts/update_entities_new.py" nella directory "python_scripts" 21 | - In alternativa, è possibile scaricare il file ZIP ed estrarre il contenuto della cartella "HA_PowerControl-main" nella cartella di Home Assistant. 22 | - [Abilitare i packages](https://www.home-assistant.io/docs/configuration/packages/) 23 | - [Abilitare gli script python](https://www.home-assistant.io/integrations/python_script/) 24 | - Aggiungere il contenuto del file "pc.lovelace" all'interfaccia Lovelace. 25 | https://github.com/andbad/HA_PowerControl/assets/7837288/73233fa8-2143-4486-bd43-1dce41e59369 26 | - Creare un gruppo di notifica "group.tutti" nel file "configuration.yaml" ed inserirvi i device che riceveranno le notifiche di intervento. 27 | - [Configurare il recoder](https://www.home-assistant.io/integrations/recorder/) per includere i seguenti sensori: 28 | - sensor.potenza_carichi_selezionato 29 | - sensor.potenza_carichi_sospesa 30 | - sensor.potenza_massima_immediato 31 | - sensor.potenza_massima_ritardato 32 | 33 | ## Configurazione 34 | Impostare i parametri di configurazione dell'interfaccia grafica Lovelace. 35 | ATTENZIONE: cliccare su "Esegui" accanto a "Salva configurazione" per salvare i parametri impostati, altrimenti andranno persi al successivo riavvio. 36 | 37 | ## Sensore potenza carichi 38 | La soluzione più efficace è utilizzare un sensore di potenza a monte dell'impianto, poco prima del contatore. In tal caso basta selezionare il sensore appropriato nella configurazione. 39 | In alternativa è possibile utilizzare i sensori di potenza dei maggiori carichi utilizzati (sensor.potenza_carichi_virtuale) e mantenere un certo margine di tolleranza. 40 | Questo comporta di monitorare tutti i maggiori carichi (forno, fornelli, phon, condizionatori, ecc...). 41 | Naturalmente in questo modo non si può valutare il consumo complessivo, quindi si potrebbe superare il valore limite senza che intervenga il controllo carichi. 42 | Ma utilizzando un valore conservativo di potenza massima (ad es. 3kW) e contando sulla tolleranze di 180 minuti fino al 33% (nell'es. 4kW) dovrebbe essere funzionale. 43 | 44 | ## Disinstallazione package 45 | Per eliminare il package basta eliminare i file che lo compongono: 46 | - ./python_scripts/update_entities.py 47 | - ./python_scripts/update_entities_new.py 48 | - ./packages/pc.yaml 49 | 50 | Eliminare la pagina nell'interfaccia (click sull'icona della matita, poi "Elimina vista").\ 51 | Eliminare il gruppo di notifica "group.tutti"\ 52 | Eliminare dal [recoder](https://www.home-assistant.io/integrations/recorder/) i seguenti sensori: 53 | - sensor.potenza_carichi_selezionato 54 | - sensor.potenza_carichi_sospesa 55 | - sensor.potenza_massima 56 | 57 | 58 | 59 | ## Screenshot 60 | ![pc_new](https://github.com/andbad/HA_PowerControl/assets/7837288/329312df-9b3c-4e11-8a57-0a11712186a2) 61 | ![1](https://user-images.githubusercontent.com/7837288/212674703-2ba39593-9dea-4e0d-8f14-76562bd82f96.png) 62 | 63 | ## Debug 64 | E' possibile attivare la scrittura di messaggi di log abilitando il componente relativo nella [sezione logger](https://www.home-assistant.io/integrations/logger/) del file di configurazione configuration.yaml: 65 | ```python 66 | logger: 67 | default: error 68 | logs: 69 | homeassistant.components.pc: debug 70 | ``` 71 | 72 | [buymecoffee]: https://www.buymeacoffee.com/andthebad 73 | [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge 74 | [commits-shield]: https://img.shields.io/github/commit-activity/y/andbad/homeassistant-carwings.svg?style=for-the-badge 75 | [commits]: https://github.com/andbad/HA_PowerControl/commits/main 76 | [forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=for-the-badge 77 | [forum]: https://github.com/indomus/forum 78 | [license-shield]: https://img.shields.io/github/license/andbad/homeassistant-carwings.svg?style=for-the-badge 79 | [maintenance-shield]: https://img.shields.io/badge/maintainer-andbad-blue.svg?style=for-the-badge 80 | [releases-shield]: https://img.shields.io/github/release/andbad/homeassistant-carwings.svg?style=for-the-badge 81 | [releases]: https://github.com/andbad/HA_PowerControl/releases 82 | [hacs-repo-badge]: https://my.home-assistant.io/badges/hacs_repository.svg 83 | -------------------------------------------------------------------------------- /packages/pc.yaml: -------------------------------------------------------------------------------- 1 | ################################################################# 2 | ################# PACKAGE CONTROLLO CARICHI ##################### 3 | ################################################################# 4 | # Autore: andbad # 5 | # GitHub: https://github.com/andbad/HA_PowerControl # 6 | # Versione: 3.70 # 7 | ################################################################# 8 | ########################### CREDITS ############################# 9 | # Un ringraziamento alla community di InDomus per l'aiuto # 10 | # ricevuto nella compilazione del seguente package. # 11 | # ----->> https://indomus.it/ <<----- # 12 | ################################################################# 13 | 14 | 15 | # Il package seguente, unito allo script python "update_entities.py" mira ad evitare il distacco del contatore a causa 16 | # della troppa potenza assorbita dai vari elettrodomestici (carichi). 17 | # Requisito hardware fondamentale è la presenza di switch sui carichi da controllare e di un sensore che misura la potenza 18 | # dei singoli carichi. 19 | # Personalmente ho utilizzato dispositivi Shelly 1PM e Shelly Plug S, perfetti per lo scopo. 20 | # E' consigliato, ma non tassativo, l'utilizzo di un sensore che monitori il consumo complessivo dell'impianto (es. Shelly EM). 21 | # La logica prevede che in caso l'utilizzo complessivo superi il valore limite impostato, il pacchetto inizi il distacco 22 | # dei carichi a minore priorità fino a quelli a maggiore priorità, fino a che l'utilizzo complessivo della potenza rientri 23 | # nel limite prefissato. 24 | # Vi sono due limiti massimi: nel caso in cui si superi il valore massimo "ritardato", il sitema attenderà alcuni minuti 25 | # (regolabili da apposita opzione) prima di procedere con il distacco; nel caso in cui si superi il valore massimo immediato, 26 | # il distacco avviene invece dopo alcuni secondi (anche in questo caso regolati da relativo slider). 27 | # Lo script tiene memoria dell'assorbimento del carico prima del distacco e lo ricollega solo quando la disponibilità 28 | # di potenza è sufficiente a non causare un nuovo distacco, a meno che non sia abilitata l'opzione specifica di non riavvio 29 | # per quel singolo carico. 30 | # La configurazione è interamente tramite interfaccia grafica, tranne il gruppo di notifica (group.tutti) che va impostato 31 | # manualmente. 32 | 33 | ################################################################# 34 | ########################## RECORDER ############################# 35 | ################################################################# 36 | # I seguenti sensori devono essere abilitati nel recorder, al fine di visualizzare lo storico di intervento nel grafico 37 | # dell'interfaccia grafica. Decommentare le seguenti righe potrebbe influire sulla configurazione del recorder in altri file. 38 | 39 | #recorder: 40 | # include: 41 | # entities: 42 | # - sensor.potenza_carichi_selezionato 43 | # - sensor.potenza_carichi_sospesa 44 | # - sensor.potenza_massima_immediato 45 | # - sensor.potenza_massima_ritardato 46 | 47 | ################################################################# 48 | ########################## SENSORI ############################## 49 | ################################################################# 50 | # La soluzione più efficace è utilizzare un sensore di potenza a monte dell'impianto, poco prima del contatore. 51 | # In tal caso basta selezionare il sensore appropriato nella configurazione. 52 | # Nell'esempio seguente è utilizzato uno ShellyEM, nel canale 1. 53 | # - platform: mqtt 54 | # name: "Potenza carichi" 55 | # state_topic: "shellies/NOME_SHELLY/emeter/0/power" 56 | # value_template: "{{ value }}" 57 | # unit_of_measurement : "W" 58 | # icon: hass:speedometer 59 | 60 | template: 61 | # In alternativa è possibile utilizzare i sensori di potenza dei maggiori carichi utilizzati e mantenere un certo margine 62 | # di tolleranza. 63 | # Questo comporta di monitorare tutti i maggiori carichi (forno, piano induzione, phon, condizionatori, ecc...). 64 | # Naturalmente in questo modo non si può valutare il consumo complessivo, quindi si potrebbe superare il valore limite 65 | # senza che intervenga il controllo carichi. 66 | # Utilizzando un valore conservativo di potenza massima (ad es. 3kW) e contando sulla tolleranze di 180 minuti fino al 80% 67 | # (nell'es. 3,6kW) è ugualmente funzionale. 68 | - sensor: 69 | - name: potenza_carichi_virtuale 70 | unit_of_measurement: 'W' 71 | device_class: power 72 | state_class: measurement 73 | state: > 74 | {{ states(states('input_text.carico_1_potenza'))|int(default=0) + 75 | states(states('input_text.carico_2_potenza'))|int(default=0) + 76 | states(states('input_text.carico_3_potenza'))|int(default=0) + 77 | states(states('input_text.carico_4_potenza'))|int(default=0) + 78 | states(states('input_text.carico_5_potenza'))|int(default=0) + 79 | states(states('input_text.carico_6_potenza'))|int(default=0) + 80 | states(states('input_text.carico_7_potenza'))|int(default=0) + 81 | states(states('input_text.carico_8_potenza'))|int(default=0) + 82 | states(states('input_text.carico_9_potenza'))|int(default=0) + 83 | states(states('input_text.carico_10_potenza'))|int(default=0) + 84 | states(states('input_text.carico_11_potenza'))|int(default=0) + 85 | states(states('input_text.carico_12_potenza'))|int(default=0) + 86 | states(states('input_text.carico_13_potenza'))|int(default=0) + 87 | states(states('input_text.carico_14_potenza'))|int(default=0) + 88 | states(states('input_text.carico_15_potenza'))|int(default=0) + 89 | states(states('input_text.carico_16_potenza'))|int(default=0) + 90 | states(states('input_text.carico_17_potenza'))|int(default=0) + 91 | states(states('input_text.carico_18_potenza'))|int(default=0) + 92 | states(states('input_text.carico_19_potenza'))|int(default=0) + 93 | states(states('input_text.carico_20_potenza'))|int(default=0) }} 94 | 95 | # Somma di tutte le potenza "sospesa", ovvero i carichi che erano in funzione con un dato assorbimento ma sono stati 96 | # disattivati. 97 | - name: potenza_carichi_sospesa 98 | unit_of_measurement: 'W' 99 | device_class: power 100 | state_class: measurement 101 | state: > 102 | {{ states('input_number.potenza_1_sospesa')|int(default=0) + 103 | states('input_number.potenza_2_sospesa')|int(default=0) + 104 | states('input_number.potenza_3_sospesa')|int(default=0) + 105 | states('input_number.potenza_4_sospesa')|int(default=0) + 106 | states('input_number.potenza_5_sospesa')|int(default=0) + 107 | states('input_number.potenza_6_sospesa')|int(default=0) + 108 | states('input_number.potenza_7_sospesa')|int(default=0) + 109 | states('input_number.potenza_8_sospesa')|int(default=0) + 110 | states('input_number.potenza_9_sospesa')|int(default=0) + 111 | states('input_number.potenza_10_sospesa')|int(default=0) + 112 | states('input_number.potenza_11_sospesa')|int(default=0) + 113 | states('input_number.potenza_12_sospesa')|int(default=0) + 114 | states('input_number.potenza_13_sospesa')|int(default=0) + 115 | states('input_number.potenza_14_sospesa')|int(default=0) + 116 | states('input_number.potenza_15_sospesa')|int(default=0) + 117 | states('input_number.potenza_16_sospesa')|int(default=0) + 118 | states('input_number.potenza_17_sospesa')|int(default=0) + 119 | states('input_number.potenza_18_sospesa')|int(default=0) + 120 | states('input_number.potenza_19_sospesa')|int(default=0) + 121 | states('input_number.potenza_20_sospesa')|int(default=0) }} 122 | 123 | # Mostra lo stato del sensore selezionato, utile per il grafico. 124 | - name: potenza_carichi_selezionato 125 | unit_of_measurement: 'W' 126 | device_class: power 127 | state_class: measurement 128 | state: "{{ states(states('input_text.potenza_carichi'))|int(default=0) }}" 129 | 130 | # Valore massimo che i carichi possono impegnare prima di cominciare il distacco 131 | - name: potenza_massima_immediato 132 | unit_of_measurement: 'W' 133 | device_class: power 134 | state_class: measurement 135 | state: "{{ states('input_number.potenza_massima_immediato')|int(default=0) }}" 136 | 137 | - name: potenza_massima_ritardato 138 | unit_of_measurement: 'W' 139 | device_class: power 140 | state_class: measurement 141 | state: "{{ states('input_number.potenza_massima_ritardato')|int(default=0) }}" 142 | 143 | ################################################################# 144 | ######################### INPUT_* ############################### 145 | ################################################################# 146 | input_text: 147 | # In questi campi viene salvato il nome delle entità selezionate dal front-end. 148 | carico_1_potenza: 149 | carico_2_potenza: 150 | carico_3_potenza: 151 | carico_4_potenza: 152 | carico_5_potenza: 153 | carico_6_potenza: 154 | carico_7_potenza: 155 | carico_8_potenza: 156 | carico_9_potenza: 157 | carico_10_potenza: 158 | carico_11_potenza: 159 | carico_12_potenza: 160 | carico_13_potenza: 161 | carico_14_potenza: 162 | carico_15_potenza: 163 | carico_16_potenza: 164 | carico_17_potenza: 165 | carico_18_potenza: 166 | carico_19_potenza: 167 | carico_20_potenza: 168 | 169 | carico_1_switch: 170 | carico_2_switch: 171 | carico_3_switch: 172 | carico_4_switch: 173 | carico_5_switch: 174 | carico_6_switch: 175 | carico_7_switch: 176 | carico_8_switch: 177 | carico_9_switch: 178 | carico_10_switch: 179 | carico_11_switch: 180 | carico_12_switch: 181 | carico_13_switch: 182 | carico_14_switch: 183 | carico_15_switch: 184 | carico_16_switch: 185 | carico_17_switch: 186 | carico_18_switch: 187 | carico_19_switch: 188 | carico_20_switch: 189 | 190 | potenza_carichi: 191 | 192 | input_boolean: 193 | # Switch per l'interfaccia grafica 194 | attiva_power_control: 195 | name: Attiva Power Control 196 | icon: hass:car-cruise-control 197 | 198 | impostazioni_power_control: 199 | name: Mostra Impostazioni Power Control 200 | icon: hass:car-cruise-control 201 | 202 | # Tiene traccia del trigger che ha innescato l'automazione di stop: 203 | # se è "0"significa che si è superata la soglia del distacco ritardato 204 | # se è "1" si è inveve superata la soglia di distacco immediato. 205 | sensore_trigger: 206 | name: sensore trigger 207 | initial: off 208 | 209 | # Se messo su on, attiva il nuovo script che filtra solo le entità che iniziano con "sensor.potenza" e "switch.interruttore" 210 | selezione_script_python: 211 | name: Selezione script Pyton 212 | 213 | mantini_spento_1: 214 | name: Mantieni spento Carico 1 215 | icon: hass:cancel 216 | mantini_spento_2: 217 | name: Mantieni spento Carico 2 218 | icon: hass:cancel 219 | mantini_spento_3: 220 | name: Mantieni spento Carico 3 221 | icon: hass:cancel 222 | mantini_spento_4: 223 | name: Mantieni spento Carico 4 224 | icon: hass:cancel 225 | mantini_spento_5: 226 | name: Mantieni spento Carico 5 227 | icon: hass:cancel 228 | mantini_spento_6: 229 | name: Mantieni spento Carico 6 230 | icon: hass:cancel 231 | mantini_spento_7: 232 | name: Mantieni spento Carico 7 233 | icon: hass:cancel 234 | mantini_spento_8: 235 | name: Mantieni spento Carico 8 236 | icon: hass:cancel 237 | mantini_spento_9: 238 | name: Mantieni spento Carico 9 239 | icon: hass:cancel 240 | mantini_spento_10: 241 | name: Mantieni spento Carico 10 242 | icon: hass:cancel 243 | mantini_spento_11: 244 | name: Mantieni spento Carico 11 245 | icon: hass:cancel 246 | mantini_spento_12: 247 | name: Mantieni spento Carico 12 248 | icon: hass:cancel 249 | mantini_spento_13: 250 | name: Mantieni spento Carico 13 251 | icon: hass:cancel 252 | mantini_spento_14: 253 | name: Mantieni spento Carico 14 254 | icon: hass:cancel 255 | mantini_spento_15: 256 | name: Mantieni spento Carico 15 257 | icon: hass:cancel 258 | mantini_spento_16: 259 | name: Mantieni spento Carico 16 260 | icon: hass:cancel 261 | mantini_spento_17: 262 | name: Mantieni spento Carico 17 263 | icon: hass:cancel 264 | mantini_spento_18: 265 | name: Mantieni spento Carico 18 266 | icon: hass:cancel 267 | mantini_spento_19: 268 | name: Mantieni spento Carico 19 269 | icon: hass:cancel 270 | mantini_spento_20: 271 | name: Mantieni spento Carico 20 272 | icon: hass:cancel 273 | 274 | input_number: 275 | 276 | # Mantengono memoria della potenza utilizzata al momento del distacco, per valutare la riattivazione. 277 | potenza_1_sospesa: 278 | min: 0 279 | max: 10000 280 | potenza_2_sospesa: 281 | min: 0 282 | max: 10000 283 | potenza_3_sospesa: 284 | min: 0 285 | max: 10000 286 | potenza_4_sospesa: 287 | min: 0 288 | max: 10000 289 | potenza_5_sospesa: 290 | min: 0 291 | max: 10000 292 | potenza_6_sospesa: 293 | min: 0 294 | max: 10000 295 | potenza_7_sospesa: 296 | min: 0 297 | max: 10000 298 | potenza_8_sospesa: 299 | min: 0 300 | max: 10000 301 | potenza_9_sospesa: 302 | min: 0 303 | max: 10000 304 | potenza_10_sospesa: 305 | min: 0 306 | max: 10000 307 | potenza_11_sospesa: 308 | min: 0 309 | max: 10000 310 | potenza_12_sospesa: 311 | min: 0 312 | max: 10000 313 | potenza_13_sospesa: 314 | min: 0 315 | max: 10000 316 | potenza_14_sospesa: 317 | min: 0 318 | max: 10000 319 | potenza_15_sospesa: 320 | min: 0 321 | max: 10000 322 | potenza_16_sospesa: 323 | min: 0 324 | max: 10000 325 | potenza_17_sospesa: 326 | min: 0 327 | max: 10000 328 | potenza_18_sospesa: 329 | min: 0 330 | max: 10000 331 | potenza_19_sospesa: 332 | min: 0 333 | max: 10000 334 | potenza_20_sospesa: 335 | min: 0 336 | max: 10000 337 | 338 | # Slider per la configurazione della potenza massima utilizzabile, superata questa soglia il distacco è immediato 339 | potenza_massima_immediato: 340 | min: 0 341 | max: 15000 342 | step: 100 343 | 344 | # Slider per la configurazione della potenza massima utilizzabile, superata questa soglia vengono attesi alcuni minuti 345 | # prima del distacco. 346 | potenza_massima_ritardato: 347 | min: 0 348 | max: 15000 349 | step: 100 350 | 351 | #Attende tot SECONDI tra un distacco e l'altro. 352 | tempo_stop_immediato: 353 | min: 5 354 | max: 60 355 | step: 1 356 | 357 | #Attende tot MINUTI tra un distacco e l'altro. 358 | tempo_stop_ritardato: 359 | min: 1 360 | max: 180 361 | step: 10 362 | 363 | #Dopo tot MINUTI che la potenza utilizzata è rientrata nei limiti, inizia a riattivare i carichi 364 | tempo_start: 365 | min: 1 366 | max: 60 367 | step: 1 368 | 369 | #Attende tot SECONDI tra un distacco e l'altro. 370 | attesa_stop: 371 | min: 5 372 | max: 60 373 | step: 1 374 | 375 | #Attende tot MINUTI tra una riattivazione e l'altra per dare il tempo al carico di riprendere il suo normale assorbimento 376 | attesa_start: 377 | min: 1 378 | max: 60 379 | step: 1 380 | 381 | 382 | input_select: 383 | # Drop-down per la configurazione di PowerControl. L'elenco di interruttori e sensori viene aggiornato all'avvio di HA. 384 | lista_carichi: 385 | name: Lista potenza carichi 386 | options: 387 | - Seleziona 388 | 389 | # Selezione del sensore di potenza utilizzata. Se non configurato, viene utilizzato il sensore virtuale 390 | potenza_carichi: 391 | name: Sensore potenza carichi 392 | options: 393 | - Seleziona 394 | 395 | # Interruttore carichi 396 | carico_1_switch: 397 | name: Interruttore Carico Priorità 1 398 | options: 399 | - Seleziona 400 | carico_2_switch: 401 | name: Interruttore Carico Priorità 2 402 | options: 403 | - Seleziona 404 | carico_3_switch: 405 | name: Interruttore Carico Priorità 3 406 | options: 407 | - Seleziona 408 | carico_4_switch: 409 | name: Interruttore Carico Priorità 4 410 | options: 411 | - Seleziona 412 | carico_5_switch: 413 | name: Interruttore Carico Priorità 5 414 | options: 415 | - Seleziona 416 | carico_6_switch: 417 | name: Interruttore Carico Priorità 6 418 | options: 419 | - Seleziona 420 | carico_7_switch: 421 | name: Interruttore Carico Priorità 7 422 | options: 423 | - Seleziona 424 | carico_8_switch: 425 | name: Interruttore Carico Priorità 8 426 | options: 427 | - Seleziona 428 | carico_9_switch: 429 | name: Interruttore Carico Priorità 9 430 | options: 431 | - Seleziona 432 | carico_10_switch: 433 | name: Interruttore Carico Priorità 10 434 | options: 435 | - Seleziona 436 | carico_11_switch: 437 | name: Interruttore Carico Priorità 11 438 | options: 439 | - Seleziona 440 | carico_12_switch: 441 | name: Interruttore Carico Priorità 12 442 | options: 443 | - Seleziona 444 | carico_13_switch: 445 | name: Interruttore Carico Priorità 13 446 | options: 447 | - Seleziona 448 | carico_14_switch: 449 | name: Interruttore Carico Priorità 14 450 | options: 451 | - Seleziona 452 | carico_15_switch: 453 | name: Interruttore Carico Priorità 15 454 | options: 455 | - Seleziona 456 | carico_16_switch: 457 | name: Interruttore Carico Priorità 16 458 | options: 459 | - Seleziona 460 | carico_17_switch: 461 | name: Interruttore Carico Priorità 17 462 | options: 463 | - Seleziona 464 | carico_18_switch: 465 | name: Interruttore Carico Priorità 18 466 | options: 467 | - Seleziona 468 | carico_19_switch: 469 | name: Interruttore Carico Priorità 19 470 | options: 471 | - Seleziona 472 | carico_20_switch: 473 | name: Interruttore Carico Priorità 20 474 | options: 475 | - Seleziona 476 | 477 | # Sensori potenza carichi 478 | carico_1_potenza: 479 | name: Sensore Carico Priorità 1 480 | options: 481 | - Seleziona 482 | carico_2_potenza: 483 | name: Sensore Carico Priorità 2 484 | options: 485 | - Seleziona 486 | carico_3_potenza: 487 | name: Sensore Carico Priorità 3 488 | options: 489 | - Seleziona 490 | carico_4_potenza: 491 | name: Sensore Carico Priorità 4 492 | options: 493 | - Seleziona 494 | carico_5_potenza: 495 | name: Sensore Carico Priorità 5 496 | options: 497 | - Seleziona 498 | carico_6_potenza: 499 | name: Sensore Carico Priorità 6 500 | options: 501 | - Seleziona 502 | carico_7_potenza: 503 | name: Sensore Carico Priorità 7 504 | options: 505 | - Seleziona 506 | carico_8_potenza: 507 | name: Sensore Carico Priorità 8 508 | options: 509 | - Seleziona 510 | carico_9_potenza: 511 | name: Sensore Carico Priorità 9 512 | options: 513 | - Seleziona 514 | carico_10_potenza: 515 | name: Sensore Carico Priorità 10 516 | options: 517 | - Seleziona 518 | carico_11_potenza: 519 | name: Sensore Carico Priorità 11 520 | options: 521 | - Seleziona 522 | carico_12_potenza: 523 | name: Sensore Carico Priorità 12 524 | options: 525 | - Seleziona 526 | carico_13_potenza: 527 | name: Sensore Carico Priorità 13 528 | options: 529 | - Seleziona 530 | carico_14_potenza: 531 | name: Sensore Carico Priorità 14 532 | options: 533 | - Seleziona 534 | carico_15_potenza: 535 | name: Sensore Carico Priorità 15 536 | options: 537 | - Seleziona 538 | carico_16_potenza: 539 | name: Sensore Carico Priorità 16 540 | options: 541 | - Seleziona 542 | carico_17_potenza: 543 | name: Sensore Carico Priorità 17 544 | options: 545 | - Seleziona 546 | carico_18_potenza: 547 | name: Sensore Carico Priorità 18 548 | options: 549 | - Seleziona 550 | carico_19_potenza: 551 | name: Sensore Carico Priorità 19 552 | options: 553 | - Seleziona 554 | carico_20_potenza: 555 | name: Sensore Carico Priorità 20 556 | options: 557 | - Seleziona 558 | 559 | timer: 560 | tempo_riattivazione: 561 | duration: "00:00:00" 562 | 563 | ################################################################# 564 | ####################### AUTOMAZIONI ############################# 565 | ################################################################# 566 | automation: 567 | 568 | # All'avvio di HA, aggiorna gli input_slider con la lista delle entità per i campi di configurazione. 569 | # All'avvio di HA attende che l'automazione "Popola entità" termini, poi carica la configurazione di interruttori 570 | # e sensori di potenza. 571 | - id: 'powercontrol_configurazione_carica' 572 | alias: PowerControl - Configurazione - Carica 573 | mode: single 574 | trigger: 575 | - platform: homeassistant 576 | event: start 577 | id: start 578 | - platform: event 579 | id: reload 580 | event_type: 581 | - automation_reloaded 582 | action: 583 | - service: system_log.write 584 | data_template: 585 | level: debug 586 | logger: homeassistant.components.pc 587 | message: "Automazione Configurazione - Carica - Lancio script configurazione" 588 | - choose: 589 | - conditions: 590 | - condition: trigger 591 | id: start 592 | sequence: 593 | - service: system_log.write 594 | data_template: 595 | level: debug 596 | logger: homeassistant.components.pc 597 | message: "HA_PowerControl Versione: 3.60.b1" 598 | - service: script.powercontrol_configurazione_popola_entita 599 | - conditions: 600 | - condition: trigger 601 | id: reload 602 | sequence: 603 | - delay: 604 | minutes: 1 605 | - service: script.powercontrol_configurazione_popola_entita 606 | - service: system_log.write 607 | data_template: 608 | level: debug 609 | logger: homeassistant.components.pc 610 | message: "Automazione Configurazione - Carica - Fine script configurazione" 611 | 612 | # Automazione che si triggera nel momento in cui la la potenza utilizzata supera la potenza massima impostata. 613 | # Agisce dopo TOT secondi dal superamento del limite, avvia lo script di distacco ed invia notifica di intervento. 614 | # Ripete l'avvio dello script di distacco finché la potenza impegnata non rientra nel limite. 615 | - id: 'powercontrol_carichi_stop' 616 | alias: PowerControl - Carichi Stop 617 | mode: single 618 | description: '' 619 | trigger: 620 | - platform: template 621 | value_template: "{{ states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_immediato')|int(default=0) }}" 622 | for: 623 | seconds: "{{ states('input_number.tempo_stop_immediato')|int(default=30) }}" 624 | id: immediato 625 | - platform: template 626 | value_template: "{{ states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_ritardato')|int(default=0) }}" 627 | for: 628 | minutes: "{{ states('input_number.tempo_stop_ritardato')|int(default=170) }}" 629 | id: ritardato 630 | condition: 631 | - condition: state 632 | entity_id: input_boolean.attiva_power_control 633 | state: 'on' 634 | action: 635 | - service: system_log.write 636 | data_template: 637 | level: debug 638 | logger: homeassistant.components.pc 639 | message: "Automazione Carichi Stop triggerata: Potenza carichi ({{ states(states('input_text.potenza_carichi'))|int }} > {{states('sensor.potenza_massima_immediato')|int}}/{{states('sensor.potenza_massima_ritardato')|int}}))" 640 | - choose: 641 | - conditions: 642 | - condition: trigger 643 | id: immediato 644 | sequence: 645 | - service: input_boolean.turn_on 646 | target: 647 | entity_id: input_boolean.sensore_trigger 648 | - service: system_log.write 649 | data_template: 650 | level: debug 651 | logger: homeassistant.components.pc 652 | message: "Automazione Carichi Stop triggerata: Tipo di innesco Immediato" 653 | - conditions: 654 | - condition: trigger 655 | id: ritardato 656 | sequence: 657 | - service: input_boolean.turn_off 658 | target: 659 | entity_id: input_boolean.sensore_trigger 660 | - service: system_log.write 661 | data_template: 662 | level: debug 663 | logger: homeassistant.components.pc 664 | message: "Automazione Carichi Stop triggerata: Tipo di innesco Ritardato" 665 | - repeat: 666 | sequence: 667 | - condition: template 668 | value_template: > 669 | {{ 670 | ((states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_ritardato')|int(default=0)) and states('input_boolean.sensore_trigger') == "off") or 671 | ((states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_immediato')|int(default=0)) and states('input_boolean.sensore_trigger') == "on") 672 | }} 673 | - service: system_log.write 674 | data_template: 675 | level: debug 676 | logger: homeassistant.components.pc 677 | message: "Avviato script stop carichi: potenza carichi {{ states(states('input_text.potenza_carichi'))|int }} Tipo: - {{ states('input_boolean.sensore_trigger') }}" 678 | - service: script.stop_carichi_generale 679 | # - if: 680 | # - condition: template 681 | # value_template: "{{ states(states('input_text.potenza_carichi'))|int(default=0) <= states('sensor.potenza_massima_immediato')|int(default=0) }}" 682 | # then: 683 | # - service: input_boolean.turn_off 684 | # target: 685 | # entity_id: input_boolean.sensore_trigger 686 | until: 687 | - condition: template 688 | value_template: > 689 | {{ 690 | ((states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_ritardato')|int(default=0)) and states('input_boolean.sensore_trigger') == "off") or 691 | ((states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_immediato')|int(default=0)) and states('input_boolean.sensore_trigger') == "on") 692 | or repeat.index == 5 693 | }} 694 | - service: input_boolean.turn_off 695 | target: 696 | entity_id: input_boolean.sensore_trigger 697 | 698 | # Se il limite di potenza è superato, fermo il timer. 699 | - id: 'powercontrol_timer_stop' 700 | alias: PowerControl - Timer Stop 701 | description: '' 702 | mode: single 703 | trigger: 704 | - platform: template 705 | value_template: "{{ states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_ritardato')|int(default=0) }}" 706 | action: 707 | - service: system_log.write 708 | data_template: 709 | level: debug 710 | logger: homeassistant.components.pc 711 | message: "Automazione stop timer triggerata: Potenza carichi+sospesa ({{ states(states('input_text.potenza_carichi'))|int + states('sensor.potenza_carichi_sospesa')|int}}) < Potenza massima ({{states('sensor.potenza_massima_ritardato')|int }}) " 712 | - service: timer.cancel 713 | data: 714 | entity_id: timer.tempo_riattivazione 715 | 716 | # Se il limite di potenza è rispettato, avvio il timer. 717 | - id: 'powercontrol_timer_start' 718 | alias: PowerControl - Timer Start 719 | description: '' 720 | mode: single 721 | trigger: 722 | - platform: template 723 | value_template: "{{ ((states(states('input_text.potenza_carichi'))|int(default=0) + states('sensor.potenza_carichi_sospesa')|int(default=0)) < states('sensor.potenza_massima_ritardato')|int(default=0)) and (states('sensor.potenza_carichi_sospesa')|int(default=0) > 0) }}" 724 | action: 725 | - service: system_log.write 726 | data_template: 727 | level: debug 728 | logger: homeassistant.components.pc 729 | message: "Automazione start timer triggerata: Potenza carichi+sospesa ({{ states(states('input_text.potenza_carichi'))|int + states('sensor.potenza_carichi_sospesa')|int}}) < Potenza massima ({{states('sensor.potenza_massima_ritardato')|int }}) " 730 | - service: timer.start 731 | data_template: 732 | duration: 00:{{ states('input_number.tempo_start') | int }}:00 733 | entity_id: timer.tempo_riattivazione 734 | 735 | 736 | # Se per TOT minuti il limite di potenza è rispettato, avvia lo script di riattivazione dei carichi fino a che la potenza "sospesa" non è zero. 737 | - id: 'powercontrol_carichi_start' 738 | alias: PowerControl - Carichi Start 739 | description: '' 740 | mode: single 741 | trigger: 742 | - platform: template 743 | value_template: "{{ ((states(states('input_text.potenza_carichi'))|int(default=0) + states('sensor.potenza_carichi_sospesa')|int(default=0)) < states('sensor.potenza_massima_ritardato')|int(default=0)) and (states('sensor.potenza_carichi_sospesa')|int(default=0) > 0) }}" 744 | for: 745 | minutes: "{{ states('input_number.tempo_start')|int(default=5) }}" 746 | condition: 747 | - condition: state 748 | entity_id: input_boolean.attiva_power_control 749 | state: 'on' 750 | - condition: template 751 | value_template: "{{ states('sensor.potenza_carichi_sospesa')|int(default=0) > 0 }}" 752 | action: 753 | - service: system_log.write 754 | data_template: 755 | level: debug 756 | logger: homeassistant.components.pc 757 | message: "Automazione start carichi triggerata: Potenza carichi+sospesa ({{ states(states('input_text.potenza_carichi'))|int + states('sensor.potenza_carichi_sospesa')|int }}) < Potenza massima ({{states('sensor.potenza_massima_ritardato')|int }}) " 758 | - repeat: 759 | until: 760 | - condition: template 761 | value_template: "{{ states('sensor.potenza_carichi_sospesa')|int(default=0) > 0 or repeat.index == 5 }}" 762 | sequence: 763 | - condition: template 764 | value_template: "{{ states('sensor.potenza_carichi_sospesa')|int(default=0) > 0 }}" 765 | - service: system_log.write 766 | data_template: 767 | level: debug 768 | logger: homeassistant.components.pc 769 | message: "Avvio script start carichi: sospesa ({{ states('sensor.potenza_carichi_sospesa')|int }})>0 " 770 | - service: script.start_carichi_generale 771 | 772 | # Controlla se un carico viene riacceso manualmente, cioè se il relativo interruttore viene attivato dall'utente, 773 | # e resetta la relativa potenza sospesa. 774 | - id: 'powercontrol_watchdog_sospesa' 775 | alias: PowerControl - Controllo su riattivazione manuale 776 | mode: single 777 | 778 | description: >- 779 | Monitora gli switch dei carichi e, se uno di questi è attivo ma la sua potenza 780 | sospesa è diversa da 0, la porta a zero. 781 | trigger: 782 | - platform: template 783 | value_template: > 784 | {{ 785 | ( states(states('input_text.carico_1_switch')) == 'on' and states('input_number.potenza_1_sospesa')|int(default=0) > 0 ) or 786 | ( states(states('input_text.carico_2_switch')) == 'on' and states('input_number.potenza_2_sospesa')|int(default=0) > 0 ) or 787 | ( states(states('input_text.carico_3_switch')) == 'on' and states('input_number.potenza_3_sospesa')|int(default=0) > 0 ) or 788 | ( states(states('input_text.carico_4_switch')) == 'on' and states('input_number.potenza_4_sospesa')|int(default=0) > 0 ) or 789 | ( states(states('input_text.carico_5_switch')) == 'on' and states('input_number.potenza_5_sospesa')|int(default=0) > 0 ) or 790 | ( states(states('input_text.carico_6_switch')) == 'on' and states('input_number.potenza_6_sospesa')|int(default=0) > 0 ) or 791 | ( states(states('input_text.carico_7_switch')) == 'on' and states('input_number.potenza_7_sospesa')|int(default=0) > 0 ) or 792 | ( states(states('input_text.carico_8_switch')) == 'on' and states('input_number.potenza_8_sospesa')|int(default=0) > 0 ) or 793 | ( states(states('input_text.carico_9_switch')) == 'on' and states('input_number.potenza_9_sospesa')|int(default=0) > 0 ) or 794 | ( states(states('input_text.carico_10_switch')) == 'on' and states('input_number.potenza_10_sospesa')|int(default=0) > 0 ) or 795 | ( states(states('input_text.carico_11_switch')) == 'on' and states('input_number.potenza_11_sospesa')|int(default=0) > 0 ) or 796 | ( states(states('input_text.carico_12_switch')) == 'on' and states('input_number.potenza_12_sospesa')|int(default=0) > 0 ) or 797 | ( states(states('input_text.carico_13_switch')) == 'on' and states('input_number.potenza_13_sospesa')|int(default=0) > 0 ) or 798 | ( states(states('input_text.carico_14_switch')) == 'on' and states('input_number.potenza_14_sospesa')|int(default=0) > 0 ) or 799 | ( states(states('input_text.carico_15_switch')) == 'on' and states('input_number.potenza_15_sospesa')|int(default=0) > 0 ) or 800 | ( states(states('input_text.carico_16_switch')) == 'on' and states('input_number.potenza_16_sospesa')|int(default=0) > 0 ) or 801 | ( states(states('input_text.carico_17_switch')) == 'on' and states('input_number.potenza_17_sospesa')|int(default=0) > 0 ) or 802 | ( states(states('input_text.carico_18_switch')) == 'on' and states('input_number.potenza_18_sospesa')|int(default=0) > 0 ) or 803 | ( states(states('input_text.carico_19_switch')) == 'on' and states('input_number.potenza_19_sospesa')|int(default=0) > 0 ) or 804 | ( states(states('input_text.carico_20_switch')) == 'on' and states('input_number.potenza_20_sospesa')|int(default=0) > 0 ) 805 | }} 806 | for: 807 | seconds: 5 808 | condition: [] 809 | action: 810 | - service: system_log.write 811 | data_template: 812 | level: debug 813 | logger: homeassistant.components.pc 814 | message: Automazione Check riattivazione manuale - Avvio 815 | - service: system_log.write 816 | data_template: 817 | level: debug 818 | logger: homeassistant.components.pc 819 | message: > 820 | Automazione Check riattivazione manuale: 821 | {% if states(states('input_text.carico_1_switch')) == 'on' and states('input_number.potenza_1_sospesa')|int(default=0) > 0 %}Carico 1: {{states('input_number.potenza_1_sospesa')|int }}W 822 | {% elif states(states('input_text.carico_2_switch')) == 'on' and states('input_number.potenza_2_sospesa')|int(default=0) > 0 %}Carico 2: {{states('input_number.potenza_2_sospesa')|int }}W 823 | {% elif states(states('input_text.carico_3_switch')) == 'on' and states('input_number.potenza_3_sospesa')|int(default=0) > 0 %}Carico 3: {{states('input_number.potenza_3_sospesa')|int }}W 824 | {% elif states(states('input_text.carico_4_switch')) == 'on' and states('input_number.potenza_4_sospesa')|int(default=0) > 0 %}Carico 4: {{states('input_number.potenza_4_sospesa')|int }}W 825 | {% elif states(states('input_text.carico_5_switch')) == 'on' and states('input_number.potenza_5_sospesa')|int(default=0) > 0 %}Carico 5: {{states('input_number.potenza_5_sospesa')|int }}W 826 | {% elif states(states('input_text.carico_6_switch')) == 'on' and states('input_number.potenza_6_sospesa')|int(default=0) > 0 %}Carico 6: {{states('input_number.potenza_6_sospesa')|int }}W 827 | {% elif states(states('input_text.carico_7_switch')) == 'on' and states('input_number.potenza_7_sospesa')|int(default=0) > 0 %}Carico 7: {{states('input_number.potenza_7_sospesa')|int }}W 828 | {% elif states(states('input_text.carico_8_switch')) == 'on' and states('input_number.potenza_8_sospesa')|int(default=0) > 0 %}Carico 8: {{states('input_number.potenza_8_sospesa')|int }}W 829 | {% elif states(states('input_text.carico_9_switch')) == 'on' and states('input_number.potenza_9_sospesa')|int(default=0) > 0 %}Carico 9: {{states('input_number.potenza_9_sospesa')|int }}W 830 | {% elif states(states('input_text.carico_10_switch')) == 'on' and states('input_number.potenza_10_sospesa')|int(default=0) > 0 %}Carico 10: {{states('input_number.potenza_10_sospesa')|int }}W 831 | {% elif states(states('input_text.carico_11_switch')) == 'on' and states('input_number.potenza_11_sospesa')|int(default=0) > 0 %}Carico 11: {{states('input_number.potenza_11_sospesa')|int }}W 832 | {% elif states(states('input_text.carico_12_switch')) == 'on' and states('input_number.potenza_12_sospesa')|int(default=0) > 0 %}Carico 12: {{states('input_number.potenza_12_sospesa')|int }}W 833 | {% elif states(states('input_text.carico_13_switch')) == 'on' and states('input_number.potenza_13_sospesa')|int(default=0) > 0 %}Carico 13: {{states('input_number.potenza_13_sospesa')|int }}W 834 | {% elif states(states('input_text.carico_14_switch')) == 'on' and states('input_number.potenza_14_sospesa')|int(default=0) > 0 %}Carico 14: {{states('input_number.potenza_14_sospesa')|int }}W 835 | {% elif states(states('input_text.carico_15_switch')) == 'on' and states('input_number.potenza_15_sospesa')|int(default=0) > 0 %}Carico 15: {{states('input_number.potenza_15_sospesa')|int }}W 836 | {% elif states(states('input_text.carico_16_switch')) == 'on' and states('input_number.potenza_16_sospesa')|int(default=0) > 0 %}Carico 16: {{states('input_number.potenza_16_sospesa')|int }}W 837 | {% elif states(states('input_text.carico_17_switch')) == 'on' and states('input_number.potenza_17_sospesa')|int(default=0) > 0 %}Carico 17: {{states('input_number.potenza_17_sospesa')|int }}W 838 | {% elif states(states('input_text.carico_18_switch')) == 'on' and states('input_number.potenza_18_sospesa')|int(default=0) > 0 %}Carico 18: {{states('input_number.potenza_18_sospesa')|int }}W 839 | {% elif states(states('input_text.carico_19_switch')) == 'on' and states('input_number.potenza_19_sospesa')|int(default=0) > 0 %}Carico 19: {{states('input_number.potenza_19_sospesa')|int }}W 840 | {% elif states(states('input_text.carico_20_switch')) == 'on' and states('input_number.potenza_20_sospesa')|int(default=0) > 0 %}Carico 20: {{states('input_number.potenza_20_sospesa')|int }}W 841 | {% else %}none 842 | {% endif %} 843 | - service: input_number.set_value 844 | data_template: 845 | value: 0 846 | entity_id: "{% if states(states('input_text.carico_1_switch')) == 'on' and states('input_number.potenza_1_sospesa')|int(default=0) > 0 %}input_number.potenza_1_sospesa 847 | {% elif states(states('input_text.carico_2_switch')) == 'on' and states('input_number.potenza_2_sospesa')|int(default=0) > 0 %}input_number.potenza_2_sospesa 848 | {% elif states(states('input_text.carico_3_switch')) == 'on' and states('input_number.potenza_3_sospesa')|int(default=0) > 0 %}input_number.potenza_3_sospesa 849 | {% elif states(states('input_text.carico_4_switch')) == 'on' and states('input_number.potenza_4_sospesa')|int(default=0) > 0 %}input_number.potenza_4_sospesa 850 | {% elif states(states('input_text.carico_5_switch')) == 'on' and states('input_number.potenza_5_sospesa')|int(default=0) > 0 %}input_number.potenza_5_sospesa 851 | {% elif states(states('input_text.carico_6_switch')) == 'on' and states('input_number.potenza_6_sospesa')|int(default=0) > 0 %}input_number.potenza_6_sospesa 852 | {% elif states(states('input_text.carico_7_switch')) == 'on' and states('input_number.potenza_7_sospesa')|int(default=0) > 0 %}input_number.potenza_7_sospesa 853 | {% elif states(states('input_text.carico_8_switch')) == 'on' and states('input_number.potenza_8_sospesa')|int(default=0) > 0 %}input_number.potenza_8_sospesa 854 | {% elif states(states('input_text.carico_9_switch')) == 'on' and states('input_number.potenza_9_sospesa')|int(default=0) > 0 %}input_number.potenza_9_sospesa 855 | {% elif states(states('input_text.carico_10_switch')) == 'on' and states('input_number.potenza_10_sospesa')|int(default=0) > 0 %}input_number.potenza_10_sospesa 856 | {% elif states(states('input_text.carico_11_switch')) == 'on' and states('input_number.potenza_11_sospesa')|int(default=0) > 0 %}input_number.potenza_11_sospesa 857 | {% elif states(states('input_text.carico_12_switch')) == 'on' and states('input_number.potenza_12_sospesa')|int(default=0) > 0 %}input_number.potenza_12_sospesa 858 | {% elif states(states('input_text.carico_13_switch')) == 'on' and states('input_number.potenza_13_sospesa')|int(default=0) > 0 %}input_number.potenza_13_sospesa 859 | {% elif states(states('input_text.carico_14_switch')) == 'on' and states('input_number.potenza_14_sospesa')|int(default=0) > 0 %}input_number.potenza_14_sospesa 860 | {% elif states(states('input_text.carico_15_switch')) == 'on' and states('input_number.potenza_15_sospesa')|int(default=0) > 0 %}input_number.potenza_15_sospesa 861 | {% elif states(states('input_text.carico_16_switch')) == 'on' and states('input_number.potenza_16_sospesa')|int(default=0) > 0 %}input_number.potenza_16_sospesa 862 | {% elif states(states('input_text.carico_17_switch')) == 'on' and states('input_number.potenza_17_sospesa')|int(default=0) > 0 %}input_number.potenza_17_sospesa 863 | {% elif states(states('input_text.carico_18_switch')) == 'on' and states('input_number.potenza_18_sospesa')|int(default=0) > 0 %}input_number.potenza_18_sospesa 864 | {% elif states(states('input_text.carico_19_switch')) == 'on' and states('input_number.potenza_19_sospesa')|int(default=0) > 0 %}input_number.potenza_11_sospesa 865 | {% elif states(states('input_text.carico_20_switch')) == 'on' and states('input_number.potenza_20_sospesa')|int(default=0) > 0 %}input_number.potenza_20_sospesa 866 | {% else %}none 867 | {% endif %}" 868 | - service: system_log.write 869 | data_template: 870 | level: debug 871 | logger: homeassistant.components.pc 872 | message: Automazione Check riattivazione manuale - Fine 873 | 874 | # All'avvio o se PowerControl viene disattivato, resetta i carichi sospesi. 875 | - id: 'powercontrol_reset_sospesa' 876 | alias: PowerControl - Reset disattivazione 877 | mode: single 878 | trigger: 879 | - platform: homeassistant 880 | event: start 881 | id: start 882 | - platform: state 883 | entity_id: 884 | - input_boolean.attiva_power_control 885 | to: "off" 886 | action: 887 | - service: system_log.write 888 | data_template: 889 | level: debug 890 | logger: homeassistant.components.pc 891 | message: "Automazione Reset sospesa - Avvio" 892 | 893 | - service: input_number.set_value 894 | data: 895 | value: 0 896 | target: 897 | entity_id: input_number.potenza_1_sospesa 898 | - service: input_number.set_value 899 | data: 900 | value: 0 901 | target: 902 | entity_id: input_number.potenza_2_sospesa 903 | - service: input_number.set_value 904 | data: 905 | value: 0 906 | target: 907 | entity_id: input_number.potenza_3_sospesa 908 | - service: input_number.set_value 909 | data: 910 | value: 0 911 | target: 912 | entity_id: input_number.potenza_4_sospesa 913 | - service: input_number.set_value 914 | data: 915 | value: 0 916 | target: 917 | entity_id: input_number.potenza_5_sospesa 918 | - service: input_number.set_value 919 | data: 920 | value: 0 921 | target: 922 | entity_id: input_number.potenza_6_sospesa 923 | - service: input_number.set_value 924 | data: 925 | value: 0 926 | target: 927 | entity_id: input_number.potenza_7_sospesa 928 | - service: input_number.set_value 929 | data: 930 | value: 0 931 | target: 932 | entity_id: input_number.potenza_8_sospesa 933 | - service: input_number.set_value 934 | data: 935 | value: 0 936 | target: 937 | entity_id: input_number.potenza_9_sospesa 938 | - service: input_number.set_value 939 | data: 940 | value: 0 941 | target: 942 | entity_id: input_number.potenza_10_sospesa 943 | - service: input_number.set_value 944 | data: 945 | value: 0 946 | target: 947 | entity_id: input_number.potenza_11_sospesa 948 | - service: input_number.set_value 949 | data: 950 | value: 0 951 | target: 952 | entity_id: input_number.potenza_12_sospesa 953 | - service: input_number.set_value 954 | data: 955 | value: 0 956 | target: 957 | entity_id: input_number.potenza_13_sospesa 958 | - service: input_number.set_value 959 | data: 960 | value: 0 961 | target: 962 | entity_id: input_number.potenza_14_sospesa 963 | - service: input_number.set_value 964 | data: 965 | value: 0 966 | target: 967 | entity_id: input_number.potenza_15_sospesa 968 | - service: input_number.set_value 969 | data: 970 | value: 0 971 | target: 972 | entity_id: input_number.potenza_16_sospesa 973 | - service: input_number.set_value 974 | data: 975 | value: 0 976 | target: 977 | entity_id: input_number.potenza_17_sospesa 978 | - service: input_number.set_value 979 | data: 980 | value: 0 981 | target: 982 | entity_id: input_number.potenza_18_sospesa 983 | - service: input_number.set_value 984 | data: 985 | value: 0 986 | target: 987 | entity_id: input_number.potenza_19_sospesa 988 | - service: input_number.set_value 989 | data: 990 | value: 0 991 | target: 992 | entity_id: input_number.potenza_20_sospesa 993 | 994 | - service: system_log.write 995 | data_template: 996 | level: debug 997 | logger: homeassistant.components.pc 998 | message: "Automazione Reset sospesa - Fine" 999 | 1000 | 1001 | ################################################################# 1002 | ######################### SCRIPT ############################### 1003 | ################################################################# 1004 | 1005 | script: 1006 | 1007 | # I carichi vengono disattivati secondo l'ordine numerico inverso (da minore priorità a maggiore). 1008 | # Attende il completamente di uno script prima di passare al successivo. 1009 | stop_carichi_generale: 1010 | alias: PowerControl - Stop carichi generale 1011 | sequence: 1012 | - service: system_log.write 1013 | data_template: 1014 | level: debug 1015 | logger: homeassistant.components.pc 1016 | message: "Avvio script stop carichi generale" 1017 | - service: system_log.write 1018 | data_template: 1019 | level: debug 1020 | logger: homeassistant.components.pc 1021 | message: "Avvio script stop carico 20" 1022 | - service: script.stop_carichi_singolo 1023 | data_template: 1024 | potenza: "{{states('input_text.carico_20_potenza')}}" 1025 | switch: "{{states('input_text.carico_20_switch')}}" 1026 | sospesa: "input_number.potenza_20_sospesa" 1027 | - service: system_log.write 1028 | data_template: 1029 | level: debug 1030 | logger: homeassistant.components.pc 1031 | message: "Avvio script stop carico 19" 1032 | - service: script.stop_carichi_singolo 1033 | data_template: 1034 | potenza: "{{states('input_text.carico_19_potenza')}}" 1035 | switch: "{{states('input_text.carico_19_switch')}}" 1036 | sospesa: "input_number.potenza_19_sospesa" 1037 | - service: system_log.write 1038 | data_template: 1039 | level: debug 1040 | logger: homeassistant.components.pc 1041 | message: "Avvio script stop carico 18" 1042 | - service: script.stop_carichi_singolo 1043 | data_template: 1044 | potenza: "{{states('input_text.carico_18_potenza')}}" 1045 | switch: "{{states('input_text.carico_18_switch')}}" 1046 | sospesa: "input_number.potenza_18_sospesa" 1047 | - service: system_log.write 1048 | data_template: 1049 | level: debug 1050 | logger: homeassistant.components.pc 1051 | message: "Avvio script stop carico 17" 1052 | - service: script.stop_carichi_singolo 1053 | data_template: 1054 | potenza: "{{states('input_text.carico_17_potenza')}}" 1055 | switch: "{{states('input_text.carico_17_switch')}}" 1056 | sospesa: "input_number.potenza_17_sospesa" 1057 | - service: system_log.write 1058 | data_template: 1059 | level: debug 1060 | logger: homeassistant.components.pc 1061 | message: "Avvio script stop carico 16" 1062 | - service: script.stop_carichi_singolo 1063 | data_template: 1064 | potenza: "{{states('input_text.carico_16_potenza')}}" 1065 | switch: "{{states('input_text.carico_16_switch')}}" 1066 | sospesa: "input_number.potenza_16_sospesa" 1067 | - service: system_log.write 1068 | data_template: 1069 | level: debug 1070 | logger: homeassistant.components.pc 1071 | message: "Avvio script stop carico 15" 1072 | - service: script.stop_carichi_singolo 1073 | data_template: 1074 | potenza: "{{states('input_text.carico_15_potenza')}}" 1075 | switch: "{{states('input_text.carico_15_switch')}}" 1076 | sospesa: "input_number.potenza_15_sospesa" 1077 | - service: system_log.write 1078 | data_template: 1079 | level: debug 1080 | logger: homeassistant.components.pc 1081 | message: "Avvio script stop carico 14" 1082 | - service: script.stop_carichi_singolo 1083 | data_template: 1084 | potenza: "{{states('input_text.carico_14_potenza')}}" 1085 | switch: "{{states('input_text.carico_14_switch')}}" 1086 | sospesa: "input_number.potenza_14_sospesa" 1087 | - service: system_log.write 1088 | data_template: 1089 | level: debug 1090 | logger: homeassistant.components.pc 1091 | message: "Avvio script stop carico 13" 1092 | - service: script.stop_carichi_singolo 1093 | data_template: 1094 | potenza: "{{states('input_text.carico_13_potenza')}}" 1095 | switch: "{{states('input_text.carico_13_switch')}}" 1096 | sospesa: "input_number.potenza_13_sospesa" 1097 | - service: system_log.write 1098 | data_template: 1099 | level: debug 1100 | logger: homeassistant.components.pc 1101 | message: "Avvio script stop carico 12" 1102 | - service: script.stop_carichi_singolo 1103 | data_template: 1104 | potenza: "{{states('input_text.carico_12_potenza')}}" 1105 | switch: "{{states('input_text.carico_12_switch')}}" 1106 | sospesa: "input_number.potenza_12_sospesa" 1107 | - service: system_log.write 1108 | data_template: 1109 | level: debug 1110 | logger: homeassistant.components.pc 1111 | message: "Avvio script stop carico 11" 1112 | - service: script.stop_carichi_singolo 1113 | data_template: 1114 | potenza: "{{states('input_text.carico_11_potenza')}}" 1115 | switch: "{{states('input_text.carico_11_switch')}}" 1116 | sospesa: "input_number.potenza_11_sospesa" 1117 | - service: system_log.write 1118 | data_template: 1119 | level: debug 1120 | logger: homeassistant.components.pc 1121 | message: "Avvio script stop carico 10" 1122 | - service: script.stop_carichi_singolo 1123 | data_template: 1124 | potenza: "{{states('input_text.carico_10_potenza')}}" 1125 | switch: "{{states('input_text.carico_10_switch')}}" 1126 | sospesa: "input_number.potenza_10_sospesa" 1127 | - service: system_log.write 1128 | data_template: 1129 | level: debug 1130 | logger: homeassistant.components.pc 1131 | message: "Avvio script stop carico 9" 1132 | - service: script.stop_carichi_singolo 1133 | data_template: 1134 | potenza: "{{states('input_text.carico_9_potenza')}}" 1135 | switch: "{{states('input_text.carico_9_switch')}}" 1136 | sospesa: "input_number.potenza_9_sospesa" 1137 | - service: system_log.write 1138 | data_template: 1139 | level: debug 1140 | logger: homeassistant.components.pc 1141 | message: "Avvio script stop carico 8" 1142 | - service: script.stop_carichi_singolo 1143 | data_template: 1144 | potenza: "{{states('input_text.carico_8_potenza')}}" 1145 | switch: "{{states('input_text.carico_8_switch')}}" 1146 | sospesa: "input_number.potenza_8_sospesa" 1147 | - service: system_log.write 1148 | data_template: 1149 | level: debug 1150 | logger: homeassistant.components.pc 1151 | message: "Avvio script stop carico 7" 1152 | - service: script.stop_carichi_singolo 1153 | data_template: 1154 | potenza: "{{states('input_text.carico_7_potenza')}}" 1155 | switch: "{{states('input_text.carico_7_switch')}}" 1156 | sospesa: "input_number.potenza_7_sospesa" 1157 | - service: system_log.write 1158 | data_template: 1159 | level: debug 1160 | logger: homeassistant.components.pc 1161 | message: "Avvio script stop carico 6" 1162 | - service: script.stop_carichi_singolo 1163 | data_template: 1164 | potenza: "{{states('input_text.carico_6_potenza')}}" 1165 | switch: "{{states('input_text.carico_6_switch')}}" 1166 | sospesa: "input_number.potenza_6_sospesa" 1167 | - service: system_log.write 1168 | data_template: 1169 | level: debug 1170 | logger: homeassistant.components.pc 1171 | message: "Avvio script stop carico 5" 1172 | - service: script.stop_carichi_singolo 1173 | data_template: 1174 | potenza: "{{states('input_text.carico_5_potenza')}}" 1175 | switch: "{{states('input_text.carico_5_switch')}}" 1176 | sospesa: "input_number.potenza_5_sospesa" 1177 | - service: system_log.write 1178 | data_template: 1179 | level: debug 1180 | logger: homeassistant.components.pc 1181 | message: "Avvio script stop carico 4" 1182 | - service: script.stop_carichi_singolo 1183 | data_template: 1184 | potenza: "{{states('input_text.carico_4_potenza')}}" 1185 | switch: "{{states('input_text.carico_4_switch')}}" 1186 | sospesa: "input_number.potenza_4_sospesa" 1187 | - service: system_log.write 1188 | data_template: 1189 | level: debug 1190 | logger: homeassistant.components.pc 1191 | message: "Avvio script stop carico 3" 1192 | - service: script.stop_carichi_singolo 1193 | data_template: 1194 | potenza: "{{states('input_text.carico_3_potenza')}}" 1195 | switch: "{{states('input_text.carico_3_switch')}}" 1196 | sospesa: "input_number.potenza_3_sospesa" 1197 | - service: system_log.write 1198 | data_template: 1199 | level: debug 1200 | logger: homeassistant.components.pc 1201 | message: "Avvio script stop carico 2" 1202 | - service: script.stop_carichi_singolo 1203 | data_template: 1204 | potenza: "{{states('input_text.carico_2_potenza')}}" 1205 | switch: "{{states('input_text.carico_2_switch')}}" 1206 | sospesa: "input_number.potenza_2_sospesa" 1207 | - service: system_log.write 1208 | data_template: 1209 | level: debug 1210 | logger: homeassistant.components.pc 1211 | message: "Avvio script stop carico 1" 1212 | - service: script.stop_carichi_singolo 1213 | data_template: 1214 | potenza: "{{states('input_text.carico_1_potenza')}}" 1215 | switch: "{{states('input_text.carico_1_switch')}}" 1216 | sospesa: "input_number.potenza_1_sospesa" 1217 | - service: system_log.write 1218 | data_template: 1219 | level: debug 1220 | logger: homeassistant.components.pc 1221 | message: "Fine script stop carichi generale" 1222 | mode: single 1223 | 1224 | # I carichi vengono riattivati secondo l'ordine numerico (da maggiore priorità a minore priorità) 1225 | # Attende il completamente di uno script prima di passare al successivo. 1226 | start_carichi_generale: 1227 | alias: PowerControl - Start carichi Generale 1228 | sequence: 1229 | - service: system_log.write 1230 | data_template: 1231 | level: debug 1232 | logger: homeassistant.components.pc 1233 | message: "Avvio script start carichi generale" 1234 | - service: system_log.write 1235 | data_template: 1236 | level: debug 1237 | logger: homeassistant.components.pc 1238 | message: "Avvio script start carico 1" 1239 | - service: script.start_carichi_singolo 1240 | data_template: 1241 | potenza: "{{states('input_text.carico_1_potenza')}}" 1242 | switch: "{{states('input_text.carico_1_switch')}}" 1243 | sospesa: "input_number.potenza_1_sospesa" 1244 | riavvio: "input_boolean.mantini_spento_1" 1245 | - service: system_log.write 1246 | data_template: 1247 | level: debug 1248 | logger: homeassistant.components.pc 1249 | message: "Avvio script start carico 2" 1250 | - service: script.start_carichi_singolo 1251 | data_template: 1252 | potenza: "{{states('input_text.carico_2_potenza')}}" 1253 | switch: "{{states('input_text.carico_2_switch')}}" 1254 | sospesa: "input_number.potenza_2_sospesa" 1255 | riavvio: "input_boolean.mantini_spento_2" 1256 | - service: system_log.write 1257 | data_template: 1258 | level: debug 1259 | logger: homeassistant.components.pc 1260 | message: "Avvio script start carico 3" 1261 | - service: script.start_carichi_singolo 1262 | data_template: 1263 | potenza: "{{states('input_text.carico_3_potenza')}}" 1264 | switch: "{{states('input_text.carico_3_switch')}}" 1265 | sospesa: "input_number.potenza_3_sospesa" 1266 | riavvio: "input_boolean.mantini_spento_3" 1267 | - service: system_log.write 1268 | data_template: 1269 | level: debug 1270 | logger: homeassistant.components.pc 1271 | message: "Avvio script start carico 4" 1272 | - service: script.start_carichi_singolo 1273 | data_template: 1274 | potenza: "{{states('input_text.carico_4_potenza')}}" 1275 | switch: "{{states('input_text.carico_4_switch')}}" 1276 | sospesa: "input_number.potenza_4_sospesa" 1277 | riavvio: "input_boolean.mantini_spento_4" 1278 | - service: system_log.write 1279 | data_template: 1280 | level: debug 1281 | logger: homeassistant.components.pc 1282 | message: "Avvio script start carico 5" 1283 | - service: script.start_carichi_singolo 1284 | data_template: 1285 | potenza: "{{states('input_text.carico_5_potenza')}}" 1286 | switch: "{{states('input_text.carico_5_switch')}}" 1287 | sospesa: "input_number.potenza_5_sospesa" 1288 | riavvio: "input_boolean.mantini_spento_5" 1289 | - service: system_log.write 1290 | data_template: 1291 | level: debug 1292 | logger: homeassistant.components.pc 1293 | message: "Avvio script start carico 6" 1294 | - service: script.start_carichi_singolo 1295 | data_template: 1296 | potenza: "{{states('input_text.carico_6_potenza')}}" 1297 | switch: "{{states('input_text.carico_6_switch')}}" 1298 | sospesa: "input_number.potenza_6_sospesa" 1299 | riavvio: "input_boolean.mantini_spento_6" 1300 | - service: system_log.write 1301 | data_template: 1302 | level: debug 1303 | logger: homeassistant.components.pc 1304 | message: "Avvio script start carico 7" 1305 | - service: script.start_carichi_singolo 1306 | data_template: 1307 | potenza: "{{states('input_text.carico_7_potenza')}}" 1308 | switch: "{{states('input_text.carico_7_switch')}}" 1309 | sospesa: "input_number.potenza_7_sospesa" 1310 | riavvio: "input_boolean.mantini_spento_7" 1311 | - service: system_log.write 1312 | data_template: 1313 | level: debug 1314 | logger: homeassistant.components.pc 1315 | message: "Avvio script start carico 8" 1316 | - service: script.start_carichi_singolo 1317 | data_template: 1318 | potenza: "{{states('input_text.carico_8_potenza')}}" 1319 | switch: "{{states('input_text.carico_8_switch')}}" 1320 | sospesa: "input_number.potenza_8_sospesa" 1321 | riavvio: "input_boolean.mantini_spento_8" 1322 | - service: system_log.write 1323 | data_template: 1324 | level: debug 1325 | logger: homeassistant.components.pc 1326 | message: "Avvio script start carico 9" 1327 | - service: script.start_carichi_singolo 1328 | data_template: 1329 | potenza: "{{states('input_text.carico_9_potenza')}}" 1330 | switch: "{{states('input_text.carico_9_switch')}}" 1331 | sospesa: "input_number.potenza_9_sospesa" 1332 | riavvio: "input_boolean.mantini_spento_9" 1333 | - service: system_log.write 1334 | data_template: 1335 | level: debug 1336 | logger: homeassistant.components.pc 1337 | message: "Avvio script start carico 10" 1338 | - service: script.start_carichi_singolo 1339 | data_template: 1340 | potenza: "{{states('input_text.carico_10_potenza')}}" 1341 | switch: "{{states('input_text.carico_10_switch')}}" 1342 | sospesa: "input_number.potenza_10_sospesa" 1343 | riavvio: "input_boolean.mantini_spento_10" 1344 | - service: system_log.write 1345 | data_template: 1346 | level: debug 1347 | logger: homeassistant.components.pc 1348 | message: "Avvio script start carico 11" 1349 | - service: script.start_carichi_singolo 1350 | data_template: 1351 | potenza: "{{states('input_text.carico_11_potenza')}}" 1352 | switch: "{{states('input_text.carico_11_switch')}}" 1353 | sospesa: "input_number.potenza_11_sospesa" 1354 | riavvio: "input_boolean.mantini_spento_11" 1355 | - service: system_log.write 1356 | data_template: 1357 | level: debug 1358 | logger: homeassistant.components.pc 1359 | message: "Avvio script start carico 12" 1360 | - service: script.start_carichi_singolo 1361 | data_template: 1362 | potenza: "{{states('input_text.carico_12_potenza')}}" 1363 | switch: "{{states('input_text.carico_12_switch')}}" 1364 | sospesa: "input_number.potenza_12_sospesa" 1365 | riavvio: "input_boolean.mantini_spento_12" 1366 | - service: system_log.write 1367 | data_template: 1368 | level: debug 1369 | logger: homeassistant.components.pc 1370 | message: "Avvio script start carico 13" 1371 | - service: script.start_carichi_singolo 1372 | data_template: 1373 | potenza: "{{states('input_text.carico_13_potenza')}}" 1374 | switch: "{{states('input_text.carico_13_switch')}}" 1375 | sospesa: "input_number.potenza_13_sospesa" 1376 | riavvio: "input_boolean.mantini_spento_13" 1377 | - service: system_log.write 1378 | data_template: 1379 | level: debug 1380 | logger: homeassistant.components.pc 1381 | message: "Avvio script start carico 14" 1382 | - service: script.start_carichi_singolo 1383 | data_template: 1384 | potenza: "{{states('input_text.carico_14_potenza')}}" 1385 | switch: "{{states('input_text.carico_14_switch')}}" 1386 | sospesa: "input_number.potenza_14_sospesa" 1387 | riavvio: "input_boolean.mantini_spento_14" 1388 | - service: system_log.write 1389 | data_template: 1390 | level: debug 1391 | logger: homeassistant.components.pc 1392 | message: "Avvio script start carico 15" 1393 | - service: script.start_carichi_singolo 1394 | data_template: 1395 | potenza: "{{states('input_text.carico_15_potenza')}}" 1396 | switch: "{{states('input_text.carico_15_switch')}}" 1397 | sospesa: "input_number.potenza_15_sospesa" 1398 | riavvio: "input_boolean.mantini_spento_15" 1399 | - service: system_log.write 1400 | data_template: 1401 | level: debug 1402 | logger: homeassistant.components.pc 1403 | message: "Avvio script start carico 16" 1404 | - service: script.start_carichi_singolo 1405 | data_template: 1406 | potenza: "{{states('input_text.carico_16_potenza')}}" 1407 | switch: "{{states('input_text.carico_16_switch')}}" 1408 | sospesa: "input_number.potenza_16_sospesa" 1409 | riavvio: "input_boolean.mantini_spento_16" 1410 | - service: system_log.write 1411 | data_template: 1412 | level: debug 1413 | logger: homeassistant.components.pc 1414 | message: "Avvio script start carico 17" 1415 | - service: script.start_carichi_singolo 1416 | data_template: 1417 | potenza: "{{states('input_text.carico_17_potenza')}}" 1418 | switch: "{{states('input_text.carico_17_switch')}}" 1419 | sospesa: "input_number.potenza_17_sospesa" 1420 | riavvio: "input_boolean.mantini_spento_17" 1421 | - service: system_log.write 1422 | data_template: 1423 | level: debug 1424 | logger: homeassistant.components.pc 1425 | message: "Avvio script start carico 18" 1426 | - service: script.start_carichi_singolo 1427 | data_template: 1428 | potenza: "{{states('input_text.carico_18_potenza')}}" 1429 | switch: "{{states('input_text.carico_18_switch')}}" 1430 | sospesa: "input_number.potenza_18_sospesa" 1431 | riavvio: "input_boolean.mantini_spento_18" 1432 | - service: system_log.write 1433 | data_template: 1434 | level: debug 1435 | logger: homeassistant.components.pc 1436 | message: "Avvio script start carico 19" 1437 | - service: script.start_carichi_singolo 1438 | data_template: 1439 | potenza: "{{states('input_text.carico_19_potenza')}}" 1440 | switch: "{{states('input_text.carico_19_switch')}}" 1441 | sospesa: "input_number.potenza_19_sospesa" 1442 | riavvio: "input_boolean.mantini_spento_19" 1443 | - service: system_log.write 1444 | data_template: 1445 | level: debug 1446 | logger: homeassistant.components.pc 1447 | message: "Avvio script start carico 20" 1448 | - service: script.start_carichi_singolo 1449 | data_template: 1450 | potenza: "{{states('input_text.carico_20_potenza')}}" 1451 | switch: "{{states('input_text.carico_20_switch')}}" 1452 | sospesa: "input_number.potenza_20_sospesa" 1453 | riavvio: "input_boolean.mantini_spento_20" 1454 | - service: system_log.write 1455 | data_template: 1456 | level: debug 1457 | logger: homeassistant.components.pc 1458 | message: "Fine script start carichi generale" 1459 | mode: single 1460 | 1461 | ################################################################# 1462 | ###################### STOP CARICHI ############################# 1463 | ################################################################# 1464 | 1465 | # Avvia il distacco del carico. 1466 | # Verifica che il carico sia configurato come sensore di potenza e come interruttore. 1467 | # Controlla se la potenza massima è superata, se il carico è acceso (potenza impegnata > 10W). 1468 | # Salva la potenza attualmente utilizzata nel relativo valore "sospesa". 1469 | # Spegne l'interruttore a monte del carico ed invia la notifica. Attende TOT secondi prima di procedere col carico successivo. 1470 | 1471 | stop_carichi_singolo: 1472 | alias: PowerControl - Stop Carico Singolo 1473 | sequence: 1474 | - service: system_log.write 1475 | data_template: 1476 | level: debug 1477 | logger: homeassistant.components.pc 1478 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Avvio" 1479 | # Controlla se il sensore potenza del carico è impostato 1480 | - condition: template 1481 | value_template: "{{ potenza != 'Seleziona' }}" 1482 | - service: system_log.write 1483 | data_template: 1484 | level: debug 1485 | logger: homeassistant.components.pc 1486 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Condition 1 - Ok" 1487 | 1488 | # Controlla se il sensore potenza del carico è disponibile 1489 | - condition: template 1490 | value_template: "{{ states(potenza) != 'unavailable' }}" 1491 | - service: system_log.write 1492 | data_template: 1493 | level: debug 1494 | logger: homeassistant.components.pc 1495 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Condition 1.5 - Ok" 1496 | 1497 | # Controlla se l'interruttore del carico è impostato 1498 | - condition: template 1499 | value_template: "{{ switch != 'Seleziona' }}" 1500 | - service: system_log.write 1501 | data_template: 1502 | level: debug 1503 | logger: homeassistant.components.pc 1504 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Condition 2 - Ok" 1505 | 1506 | # Controlla se l'interruttore del carico è disponibile 1507 | - condition: template 1508 | value_template: "{{ states(switch) != 'unavailable' }}" 1509 | - service: system_log.write 1510 | data_template: 1511 | level: debug 1512 | logger: homeassistant.components.pc 1513 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Condition 2.5 - Ok" 1514 | 1515 | # Controlla se la potenza in uso è maggiore dei limiti impostati 1516 | - condition: template 1517 | value_template: > 1518 | {{ 1519 | ((states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_ritardato')|int(default=0)) and states('input_boolean.sensore_trigger') == "off") or 1520 | ((states(states('input_text.potenza_carichi'))|int(default=0) > states('sensor.potenza_massima_immediato')|int(default=0)) and states('input_boolean.sensore_trigger') == "on") 1521 | }} 1522 | - service: system_log.write 1523 | data_template: 1524 | level: debug 1525 | logger: homeassistant.components.pc 1526 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Condition 3 - Ok {{ states(states('input_text.potenza_carichi'))|int }}W" 1527 | # Controlla se il carico è attualmente in uso 1528 | - condition: template 1529 | value_template: "{{ states(potenza)|int(default=0) > 10 }}" 1530 | - service: system_log.write 1531 | data_template: 1532 | level: debug 1533 | logger: homeassistant.components.pc 1534 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Condition 4 - Ok" 1535 | #Salvo potenza in uso dal carico sul relativo sensore sospesa 1536 | - service: input_number.set_value 1537 | data_template: 1538 | value: "{{ states(potenza)|int }}" 1539 | entity_id: "{{sospesa}}" 1540 | - service: system_log.write 1541 | data_template: 1542 | level: debug 1543 | logger: homeassistant.components.pc 1544 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Spostata potenza da carico {{ states(potenza)|int }} a sospesa {{ states(sospesa)|int }} (dovrebbero essere uguali)." 1545 | # Spengo il carico 1546 | - service_template: switch.turn_off 1547 | data_template: 1548 | entity_id: "{{ switch }}" 1549 | - service: system_log.write 1550 | data_template: 1551 | level: debug 1552 | logger: homeassistant.components.pc 1553 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Spento carico" 1554 | #Invio Notifica 1555 | - service: notify.tutti 1556 | continue_on_error: true 1557 | data: 1558 | title: Limite potenza superato 1559 | message: "{{ state_attr(switch,'friendly_name') }} disattivato." 1560 | data: 1561 | push: 1562 | thread-id: "powercontrol" 1563 | - service: system_log.write 1564 | data_template: 1565 | level: debug 1566 | logger: homeassistant.components.pc 1567 | message: "Script Stop Carico {{ state_attr(switch,'friendly_name') }} - Inviata notifica. Attendo {{ states('input_number.attesa_stop') }} secondi " 1568 | 1569 | # Attendo prima di passare al prossimo carico da distaccare. 1570 | - delay: 1571 | seconds: "{{ states('input_number.attesa_stop') }}" 1572 | mode: single 1573 | 1574 | 1575 | 1576 | ################################################################# 1577 | ###################### START CARICHI ############################ 1578 | ################################################################# 1579 | 1580 | # Script per la riattivazione dei carichi. 1581 | # Controlla che il carico sia abilitato alla riattivazzione 1582 | # Verifica che il carico si aconfigurato come seonsore di potenza e come interruttore. 1583 | # Controlla che il carico sia stato disattivato (potenza in attesa) 1584 | # Controlla che il limite di potenza venga rispettato. 1585 | # Controlla anche se riattivando il carico (ipotizzando un consumo pari a quello che aveva all'atto della disattivazione) 1586 | # non supera il valore massimo. 1587 | # Quest'ultimo controllo serve ad evitare che si riattacchi un carico che poi si ristacchi dopo pochi secondi perché ha 1588 | # causato un nuovo sforamento del limite. 1589 | # Imposta il relativo valore "sospesa" a zero, riattiva l'interruttore ed invia una notifica di riattivazione. 1590 | # Infine attende TOT minuti prima di passare al carico successivo. 1591 | 1592 | start_carichi_singolo: 1593 | alias: PowerControl - Start Carico Singolo 1594 | sequence: 1595 | - service: system_log.write 1596 | data_template: 1597 | level: debug 1598 | logger: homeassistant.components.pc 1599 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Avvio" 1600 | 1601 | # Controllo se il sensore potenza del carico è stato configurato 1602 | - condition: template 1603 | value_template: "{{ potenza != 'Seleziona' }}" 1604 | - service: system_log.write 1605 | data_template: 1606 | level: debug 1607 | logger: homeassistant.components.pc 1608 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 1 ok" 1609 | 1610 | # Controlla se il sensore potenza del carico è disponibile 1611 | - condition: template 1612 | value_template: "{{ states(potenza) != 'unavailable' }}" 1613 | - service: system_log.write 1614 | data_template: 1615 | level: debug 1616 | logger: homeassistant.components.pc 1617 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 1.5 - Ok" 1618 | 1619 | # Controllo se l'interruttore del carico è stato configurato 1620 | - condition: template 1621 | value_template: "{{ switch != 'Seleziona' }}" 1622 | - service: system_log.write 1623 | data_template: 1624 | level: debug 1625 | logger: homeassistant.components.pc 1626 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 2 ok" 1627 | 1628 | # Controlla se l'interruttore del carico è disponibile 1629 | - condition: template 1630 | value_template: "{{ states(switch) != 'unavailable' }}" 1631 | - service: system_log.write 1632 | data_template: 1633 | level: debug 1634 | logger: homeassistant.components.pc 1635 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 2.5 - Ok" 1636 | 1637 | # Controllo che il carico sia abilitato alla riattivazione 1638 | - service: system_log.write 1639 | data_template: 1640 | level: debug 1641 | logger: homeassistant.components.pc 1642 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 2.75 {{states(riavvio)}}" 1643 | - condition: template 1644 | value_template: "{{ states(riavvio) == 'off' }}" 1645 | - service: system_log.write 1646 | data_template: 1647 | level: debug 1648 | logger: homeassistant.components.pc 1649 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 2.75 ok" 1650 | 1651 | # Verifica se la potenza sospesa del carico è maggiore di 0 (in questo caso il carico è stato spento dal contollo carichi) 1652 | - condition: template 1653 | value_template: "{{ states(sospesa)|int(default=0) > 0 }}" 1654 | - service: system_log.write 1655 | data_template: 1656 | level: debug 1657 | logger: homeassistant.components.pc 1658 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 3 ok" 1659 | # Verifico che la potenza in uso sia inferiore alla potenza massima ritardato. 1660 | - condition: template 1661 | value_template: "{{ states(states('input_text.potenza_carichi'))|int(default=0) < states('sensor.potenza_massima_ritardato')|int(default=0)}}" 1662 | - service: system_log.write 1663 | data_template: 1664 | level: debug 1665 | logger: homeassistant.components.pc 1666 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 4 ok" 1667 | #Controlla se, riattivanado il carico, non si superi nuovamente il limite di potenza. 1668 | - condition: template 1669 | value_template: "{{ states(states('input_text.potenza_carichi'))|int(default=0) + states(sospesa)|int(default=0) < states('sensor.potenza_massima_ritardato')|int(default=0) }}" 1670 | - service: system_log.write 1671 | data_template: 1672 | level: debug 1673 | logger: homeassistant.components.pc 1674 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Condition 5 ok" 1675 | # Imposta la potenza sospesa del carico a zero. 1676 | - service: input_number.set_value 1677 | data_template: 1678 | value: 0 1679 | entity_id: "{{sospesa}}" 1680 | - service: system_log.write 1681 | data_template: 1682 | level: debug 1683 | logger: homeassistant.components.pc 1684 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Resettata potenza sospesa" 1685 | #Accendo il carico 1686 | - service_template: switch.turn_on 1687 | data_template: 1688 | entity_id: "{{ switch }}" 1689 | - service: system_log.write 1690 | data_template: 1691 | level: debug 1692 | logger: homeassistant.components.pc 1693 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Attivato interruttore" 1694 | # Invio notifica 1695 | - service: notify.tutti 1696 | continue_on_error: true 1697 | data: 1698 | title: Limite potenza rientrato 1699 | message: "{{ state_attr(switch,'friendly_name') }} Riattivato" 1700 | data: 1701 | push: 1702 | thread-id: "powercontrol" 1703 | #Resetto il timer 1704 | - service: timer.start 1705 | data_template: 1706 | duration: 00:{{ states('input_number.attesa_start') | int }}:00 1707 | entity_id: timer.tempo_riattivazione 1708 | 1709 | - service: system_log.write 1710 | data_template: 1711 | level: debug 1712 | logger: homeassistant.components.pc 1713 | message: "Script Start Carico {{ state_attr(switch,'friendly_name') }} - Inviata notifica. Attendo {{ states('input_number.attesa_start') }} minuti" 1714 | - delay: 1715 | minutes: "{{ states('input_number.attesa_start') }}" 1716 | mode: single 1717 | 1718 | 1719 | 1720 | ################################################################# 1721 | ###################### CONFIGURAZIONE ########################### 1722 | ################################################################# 1723 | 1724 | # All'avvio di HA, aggiorna gli input_slider con la lista delle entità per i campi di configurazione. 1725 | powercontrol_configurazione_popola_entita: 1726 | alias: PowerControl - Configurazione - Popola entità 1727 | sequence: 1728 | - service: system_log.write 1729 | data_template: 1730 | level: debug 1731 | logger: homeassistant.components.pc 1732 | message: "Script Configurazione - Popola entità - Avvio script python" 1733 | - choose: 1734 | - conditions: 1735 | - condition: state 1736 | entity_id: input_boolean.selezione_script_python 1737 | state: 'off' 1738 | sequence: 1739 | - service: python_script.update_entities 1740 | - conditions: 1741 | - condition: state 1742 | entity_id: input_boolean.selezione_script_python 1743 | state: 'on' 1744 | sequence: 1745 | - service: python_script.update_entities_new 1746 | - service: system_log.write 1747 | data_template: 1748 | level: debug 1749 | logger: homeassistant.components.pc 1750 | message: "Script Configurazione - Popola entità - Script python terminato" 1751 | 1752 | - service: system_log.write 1753 | data_template: 1754 | level: debug 1755 | logger: homeassistant.components.pc 1756 | message: "Script Configurazione - Carica - Carico input_select dai relativi input_text" 1757 | - service: input_select.select_option 1758 | data: 1759 | entity_id: input_select.potenza_carichi 1760 | option: "{{ states('input_text.potenza_carichi') }}" 1761 | - service: input_select.select_option 1762 | data: 1763 | entity_id: input_select.carico_1_potenza 1764 | option: "{{ states('input_text.carico_1_potenza') }}" 1765 | - service: input_select.select_option 1766 | data: 1767 | entity_id: input_select.carico_2_potenza 1768 | option: "{{ states('input_text.carico_2_potenza') }}" 1769 | - service: input_select.select_option 1770 | data: 1771 | entity_id: input_select.carico_3_potenza 1772 | option: "{{ states('input_text.carico_3_potenza') }}" 1773 | - service: input_select.select_option 1774 | data: 1775 | entity_id: input_select.carico_4_potenza 1776 | option: "{{ states('input_text.carico_4_potenza') }}" 1777 | - service: input_select.select_option 1778 | data: 1779 | entity_id: input_select.carico_5_potenza 1780 | option: "{{ states('input_text.carico_5_potenza') }}" 1781 | - service: input_select.select_option 1782 | data: 1783 | entity_id: input_select.carico_6_potenza 1784 | option: "{{ states('input_text.carico_6_potenza') }}" 1785 | - service: input_select.select_option 1786 | data: 1787 | entity_id: input_select.carico_7_potenza 1788 | option: "{{ states('input_text.carico_7_potenza') }}" 1789 | - service: input_select.select_option 1790 | data: 1791 | entity_id: input_select.carico_8_potenza 1792 | option: "{{ states('input_text.carico_8_potenza') }}" 1793 | - service: input_select.select_option 1794 | data: 1795 | entity_id: input_select.carico_9_potenza 1796 | option: "{{ states('input_text.carico_9_potenza') }}" 1797 | - service: input_select.select_option 1798 | data: 1799 | entity_id: input_select.carico_10_potenza 1800 | option: "{{ states('input_text.carico_10_potenza') }}" 1801 | - service: input_select.select_option 1802 | data: 1803 | entity_id: input_select.carico_11_potenza 1804 | option: "{{ states('input_text.carico_11_potenza') }}" 1805 | - service: input_select.select_option 1806 | data: 1807 | entity_id: input_select.carico_12_potenza 1808 | option: "{{ states('input_text.carico_12_potenza') }}" 1809 | - service: input_select.select_option 1810 | data: 1811 | entity_id: input_select.carico_13_potenza 1812 | option: "{{ states('input_text.carico_13_potenza') }}" 1813 | - service: input_select.select_option 1814 | data: 1815 | entity_id: input_select.carico_14_potenza 1816 | option: "{{ states('input_text.carico_14_potenza') }}" 1817 | - service: input_select.select_option 1818 | data: 1819 | entity_id: input_select.carico_15_potenza 1820 | option: "{{ states('input_text.carico_15_potenza') }}" 1821 | - service: input_select.select_option 1822 | data: 1823 | entity_id: input_select.carico_16_potenza 1824 | option: "{{ states('input_text.carico_16_potenza') }}" 1825 | - service: input_select.select_option 1826 | data: 1827 | entity_id: input_select.carico_17_potenza 1828 | option: "{{ states('input_text.carico_17_potenza') }}" 1829 | - service: input_select.select_option 1830 | data: 1831 | entity_id: input_select.carico_18_potenza 1832 | option: "{{ states('input_text.carico_18_potenza') }}" 1833 | - service: input_select.select_option 1834 | data: 1835 | entity_id: input_select.carico_19_potenza 1836 | option: "{{ states('input_text.carico_19_potenza') }}" 1837 | - service: input_select.select_option 1838 | data: 1839 | entity_id: input_select.carico_20_potenza 1840 | option: "{{ states('input_text.carico_20_potenza') }}" 1841 | 1842 | 1843 | - service: input_select.select_option 1844 | data: 1845 | entity_id: input_select.carico_1_switch 1846 | option: "{{ states('input_text.carico_1_switch') }}" 1847 | - service: input_select.select_option 1848 | data: 1849 | entity_id: input_select.carico_2_switch 1850 | option: "{{ states('input_text.carico_2_switch') }}" 1851 | - service: input_select.select_option 1852 | data: 1853 | entity_id: input_select.carico_3_switch 1854 | option: "{{ states('input_text.carico_3_switch') }}" 1855 | - service: input_select.select_option 1856 | data: 1857 | entity_id: input_select.carico_4_switch 1858 | option: "{{ states('input_text.carico_4_switch') }}" 1859 | - service: input_select.select_option 1860 | data: 1861 | entity_id: input_select.carico_5_switch 1862 | option: "{{ states('input_text.carico_5_switch') }}" 1863 | - service: input_select.select_option 1864 | data: 1865 | entity_id: input_select.carico_6_switch 1866 | option: "{{ states('input_text.carico_6_switch') }}" 1867 | - service: input_select.select_option 1868 | data: 1869 | entity_id: input_select.carico_7_switch 1870 | option: "{{ states('input_text.carico_7_switch') }}" 1871 | - service: input_select.select_option 1872 | data: 1873 | entity_id: input_select.carico_8_switch 1874 | option: "{{ states('input_text.carico_8_switch') }}" 1875 | - service: input_select.select_option 1876 | data: 1877 | entity_id: input_select.carico_9_switch 1878 | option: "{{ states('input_text.carico_9_switch') }}" 1879 | - service: input_select.select_option 1880 | data: 1881 | entity_id: input_select.carico_10_switch 1882 | option: "{{ states('input_text.carico_10_switch') }}" 1883 | - service: input_select.select_option 1884 | data: 1885 | entity_id: input_select.carico_11_switch 1886 | option: "{{ states('input_text.carico_11_switch') }}" 1887 | - service: input_select.select_option 1888 | data: 1889 | entity_id: input_select.carico_12_switch 1890 | option: "{{ states('input_text.carico_12_switch') }}" 1891 | - service: input_select.select_option 1892 | data: 1893 | entity_id: input_select.carico_13_switch 1894 | option: "{{ states('input_text.carico_13_switch') }}" 1895 | - service: input_select.select_option 1896 | data: 1897 | entity_id: input_select.carico_14_switch 1898 | option: "{{ states('input_text.carico_14_switch') }}" 1899 | - service: input_select.select_option 1900 | data: 1901 | entity_id: input_select.carico_15_switch 1902 | option: "{{ states('input_text.carico_15_switch') }}" 1903 | - service: input_select.select_option 1904 | data: 1905 | entity_id: input_select.carico_16_switch 1906 | option: "{{ states('input_text.carico_16_switch') }}" 1907 | - service: input_select.select_option 1908 | data: 1909 | entity_id: input_select.carico_17_switch 1910 | option: "{{ states('input_text.carico_17_switch') }}" 1911 | - service: input_select.select_option 1912 | data: 1913 | entity_id: input_select.carico_18_switch 1914 | option: "{{ states('input_text.carico_18_switch') }}" 1915 | - service: input_select.select_option 1916 | data: 1917 | entity_id: input_select.carico_19_switch 1918 | option: "{{ states('input_text.carico_19_switch') }}" 1919 | - service: input_select.select_option 1920 | data: 1921 | entity_id: input_select.carico_20_switch 1922 | option: "{{ states('input_text.carico_20_switch') }}" 1923 | 1924 | - service: system_log.write 1925 | data_template: 1926 | level: debug 1927 | logger: homeassistant.components.pc 1928 | message: "Script Configurazione - Carica - Fine caricamento" 1929 | 1930 | # Aggiorna gli input_slider con la lista delle entità per i campi di configurazione quando richiamato da pannello di configurazione 1931 | powercontrol_configurazione_salva: 1932 | alias: PowerControl - Configurazione - Salva 1933 | sequence: 1934 | - service: system_log.write 1935 | data_template: 1936 | level: debug 1937 | logger: homeassistant.components.pc 1938 | message: "Script Configurazione - Salva - Avvio automazione, attendo fine automazione powercontrol_configurazione_carica" 1939 | - wait_template: "{{ state_attr('automation.powercontrol_configurazione_carica','current') == 0 }}" 1940 | - service: system_log.write 1941 | 1942 | data_template: 1943 | level: debug 1944 | logger: homeassistant.components.pc 1945 | message: "Script Configurazione - Salva - Salvo input_select in input_text" 1946 | - service: input_text.set_value 1947 | data: 1948 | entity_id: input_text.potenza_carichi 1949 | value: "{{ states('input_select.potenza_carichi') }}" 1950 | 1951 | - service: input_text.set_value 1952 | data: 1953 | entity_id: input_text.carico_1_potenza 1954 | value: "{{ states('input_select.carico_1_potenza') }}" 1955 | - service: input_text.set_value 1956 | data: 1957 | entity_id: input_text.carico_2_potenza 1958 | value: "{{ states('input_select.carico_2_potenza') }}" 1959 | - service: input_text.set_value 1960 | data: 1961 | entity_id: input_text.carico_3_potenza 1962 | value: "{{ states('input_select.carico_3_potenza') }}" 1963 | - service: input_text.set_value 1964 | data: 1965 | entity_id: input_text.carico_4_potenza 1966 | value: "{{ states('input_select.carico_4_potenza') }}" 1967 | - service: input_text.set_value 1968 | data: 1969 | entity_id: input_text.carico_5_potenza 1970 | value: "{{ states('input_select.carico_5_potenza') }}" 1971 | - service: input_text.set_value 1972 | data: 1973 | entity_id: input_text.carico_6_potenza 1974 | value: "{{ states('input_select.carico_6_potenza') }}" 1975 | - service: input_text.set_value 1976 | data: 1977 | entity_id: input_text.carico_7_potenza 1978 | value: "{{ states('input_select.carico_7_potenza') }}" 1979 | - service: input_text.set_value 1980 | data: 1981 | entity_id: input_text.carico_8_potenza 1982 | value: "{{ states('input_select.carico_8_potenza') }}" 1983 | - service: input_text.set_value 1984 | data: 1985 | entity_id: input_text.carico_9_potenza 1986 | value: "{{ states('input_select.carico_9_potenza') }}" 1987 | - service: input_text.set_value 1988 | data: 1989 | entity_id: input_text.carico_10_potenza 1990 | value: "{{ states('input_select.carico_10_potenza') }}" 1991 | - service: input_text.set_value 1992 | data: 1993 | entity_id: input_text.carico_11_potenza 1994 | value: "{{ states('input_select.carico_11_potenza') }}" 1995 | - service: input_text.set_value 1996 | data: 1997 | entity_id: input_text.carico_12_potenza 1998 | value: "{{ states('input_select.carico_12_potenza') }}" 1999 | - service: input_text.set_value 2000 | data: 2001 | entity_id: input_text.carico_13_potenza 2002 | value: "{{ states('input_select.carico_13_potenza') }}" 2003 | - service: input_text.set_value 2004 | data: 2005 | entity_id: input_text.carico_14_potenza 2006 | value: "{{ states('input_select.carico_14_potenza') }}" 2007 | - service: input_text.set_value 2008 | data: 2009 | entity_id: input_text.carico_15_potenza 2010 | value: "{{ states('input_select.carico_15_potenza') }}" 2011 | - service: input_text.set_value 2012 | data: 2013 | entity_id: input_text.carico_16_potenza 2014 | value: "{{ states('input_select.carico_16_potenza') }}" 2015 | - service: input_text.set_value 2016 | data: 2017 | entity_id: input_text.carico_17_potenza 2018 | value: "{{ states('input_select.carico_17_potenza') }}" 2019 | - service: input_text.set_value 2020 | data: 2021 | entity_id: input_text.carico_18_potenza 2022 | value: "{{ states('input_select.carico_18_potenza') }}" 2023 | - service: input_text.set_value 2024 | data: 2025 | entity_id: input_text.carico_19_potenza 2026 | value: "{{ states('input_select.carico_19_potenza') }}" 2027 | - service: input_text.set_value 2028 | data: 2029 | entity_id: input_text.carico_20_potenza 2030 | value: "{{ states('input_select.carico_20_potenza') }}" 2031 | 2032 | - service: input_text.set_value 2033 | data: 2034 | entity_id: input_text.carico_1_switch 2035 | value: "{{ states('input_select.carico_1_switch') }}" 2036 | - service: input_text.set_value 2037 | data: 2038 | entity_id: input_text.carico_2_switch 2039 | value: "{{ states('input_select.carico_2_switch') }}" 2040 | - service: input_text.set_value 2041 | data: 2042 | entity_id: input_text.carico_3_switch 2043 | value: "{{ states('input_select.carico_3_switch') }}" 2044 | - service: input_text.set_value 2045 | data: 2046 | entity_id: input_text.carico_4_switch 2047 | value: "{{ states('input_select.carico_4_switch') }}" 2048 | - service: input_text.set_value 2049 | data: 2050 | entity_id: input_text.carico_5_switch 2051 | value: "{{ states('input_select.carico_5_switch') }}" 2052 | - service: input_text.set_value 2053 | data: 2054 | entity_id: input_text.carico_6_switch 2055 | value: "{{ states('input_select.carico_6_switch') }}" 2056 | - service: input_text.set_value 2057 | data: 2058 | entity_id: input_text.carico_7_switch 2059 | value: "{{ states('input_select.carico_7_switch') }}" 2060 | - service: input_text.set_value 2061 | data: 2062 | entity_id: input_text.carico_8_switch 2063 | value: "{{ states('input_select.carico_8_switch') }}" 2064 | - service: input_text.set_value 2065 | data: 2066 | entity_id: input_text.carico_9_switch 2067 | value: "{{ states('input_select.carico_9_switch') }}" 2068 | - service: input_text.set_value 2069 | data: 2070 | entity_id: input_text.carico_10_switch 2071 | value: "{{ states('input_select.carico_10_switch') }}" 2072 | - service: input_text.set_value 2073 | data: 2074 | entity_id: input_text.carico_11_switch 2075 | value: "{{ states('input_select.carico_11_switch') }}" 2076 | - service: input_text.set_value 2077 | data: 2078 | entity_id: input_text.carico_12_switch 2079 | value: "{{ states('input_select.carico_12_switch') }}" 2080 | - service: input_text.set_value 2081 | data: 2082 | entity_id: input_text.carico_13_switch 2083 | value: "{{ states('input_select.carico_13_switch') }}" 2084 | - service: input_text.set_value 2085 | data: 2086 | entity_id: input_text.carico_14_switch 2087 | value: "{{ states('input_select.carico_14_switch') }}" 2088 | - service: input_text.set_value 2089 | data: 2090 | entity_id: input_text.carico_15_switch 2091 | value: "{{ states('input_select.carico_15_switch') }}" 2092 | - service: input_text.set_value 2093 | data: 2094 | entity_id: input_text.carico_16_switch 2095 | value: "{{ states('input_select.carico_16_switch') }}" 2096 | - service: input_text.set_value 2097 | data: 2098 | entity_id: input_text.carico_17_switch 2099 | value: "{{ states('input_select.carico_17_switch') }}" 2100 | - service: input_text.set_value 2101 | data: 2102 | entity_id: input_text.carico_18_switch 2103 | value: "{{ states('input_select.carico_18_switch') }}" 2104 | - service: input_text.set_value 2105 | data: 2106 | entity_id: input_text.carico_19_switch 2107 | value: "{{ states('input_select.carico_19_switch') }}" 2108 | - service: input_text.set_value 2109 | data: 2110 | entity_id: input_text.carico_20_switch 2111 | value: "{{ states('input_select.carico_20_switch') }}" 2112 | 2113 | - service: system_log.write 2114 | data_template: 2115 | level: debug 2116 | logger: homeassistant.components.pc 2117 | message: "Script Configurazione - Salva - Fine salvataggio" 2118 | -------------------------------------------------------------------------------- /pc.lovelace: -------------------------------------------------------------------------------- 1 | theme: Backend-selected 2 | title: PC 3 | path: pc 4 | icon: hass:car-cruise-control 5 | cards: 6 | - type: markdown 7 | content: "**Power Control v.3.70**" 8 | - type: vertical-stack 9 | cards: 10 | - type: history-graph 11 | entities: 12 | - entity: sensor.potenza_massima_ritardato 13 | name: Massima 14 | - entity: sensor.potenza_carichi_selezionato 15 | name: In uso 16 | - entity: sensor.potenza_carichi_sospesa 17 | name: In attesa 18 | refresh_interval: 0 19 | title: Grafico Potenza 20 | hours_to_show: 2 21 | - type: entities 22 | entities: 23 | - entity: input_boolean.attiva_power_control 24 | icon: hass:car-cruise-control 25 | - entity: input_boolean.impostazioni_power_control 26 | icon: hass:car-cruise-control 27 | - entity: sensor.potenza_carichi_selezionato 28 | name: Potenza in uso 29 | icon: hass:power-plug 30 | - entity: sensor.potenza_carichi_sospesa 31 | name: Potenza in attesa 32 | icon: hass:power-plug-off 33 | - entity: script.powercontrol_configurazione_salva 34 | name: Salva Configurazione 35 | icon: mdi:floppy 36 | - entity: timer.tempo_riattivazione 37 | name: Timer riattivazione prossimo carico 38 | state_color: true 39 | show_header_toggle: false 40 | - type: horizontal-stack 41 | cards: 42 | - type: markdown 43 | content: >- 44 | {%if states(states('input_text.carico_1_potenza'))|int(default=0) 45 | > 5 %} 46 | {{state_attr(states('input_text.carico_1_potenza'),'friendly_name')}}: 47 | {{states(states('input_text.carico_1_potenza')) }} W 48 | 49 | {%endif%} {%if 50 | states(states('input_text.carico_2_potenza'))|int(default=0) > 5 51 | %} 52 | {{state_attr(states('input_text.carico_2_potenza'),'friendly_name')}}: 53 | {{states(states('input_text.carico_2_potenza')) }} W 54 | 55 | {%endif%} {%if 56 | states(states('input_text.carico_3_potenza'))|int(default=0) > 5 57 | %} 58 | {{state_attr(states('input_text.carico_3_potenza'),'friendly_name')}}: 59 | {{states(states('input_text.carico_3_potenza')) }} W 60 | 61 | {%endif%} {%if 62 | states(states('input_text.carico_4_potenza'))|int(default=0) > 5 63 | %} 64 | {{state_attr(states('input_text.carico_4_potenza'),'friendly_name')}}: 65 | {{states(states('input_text.carico_4_potenza')) }} W 66 | 67 | {%endif%} {%if 68 | states(states('input_text.carico_5_potenza'))|int(default=0) > 5 69 | %} 70 | {{state_attr(states('input_text.carico_5_potenza'),'friendly_name')}}: 71 | {{states(states('input_text.carico_5_potenza')) }} W 72 | 73 | {%endif%} {%if 74 | states(states('input_text.carico_6_potenza'))|int(default=0) > 5 75 | %} 76 | {{state_attr(states('input_text.carico_6_potenza'),'friendly_name')}}: 77 | {{states(states('input_text.carico_6_potenza')) }} W 78 | 79 | {%endif%} {%if 80 | states(states('input_text.carico_7_potenza'))|int(default=0) > 5 81 | %} 82 | {{state_attr(states('input_text.carico_7_potenza'),'friendly_name')}}: 83 | {{states(states('input_text.carico_7_potenza')) }} W 84 | 85 | {%endif%} {%if 86 | states(states('input_text.carico_8_potenza'))|int(default=0) > 5 87 | %} 88 | {{state_attr(states('input_text.carico_8_potenza'),'friendly_name')}}: 89 | {{states(states('input_text.carico_8_potenza')) }} W 90 | 91 | {%endif%} {%if 92 | states(states('input_text.carico_9_potenza'))|int(default=0) > 5 93 | %} 94 | {{state_attr(states('input_text.carico_9_potenza'),'friendly_name')}}: 95 | {{states(states('input_text.carico_9_potenza')) }} W 96 | 97 | {%endif%} {%if 98 | states(states('input_text.carico_10_potenza'))|int(default=0) > 5 99 | %} 100 | {{state_attr(states('input_text.carico_10_potenza'),'friendly_name')}}: 101 | {{states(states('input_text.carico_10_potenza')) }} W 102 | 103 | {%endif%} {%if 104 | states(states('input_text.carico_11_potenza'))|int(default=0) > 5 105 | %} 106 | {{state_attr(states('input_text.carico_11_potenza'),'friendly_name')}}: 107 | {{states(states('input_text.carico_11_potenza')) }} W 108 | 109 | {%endif%} {%if 110 | states(states('input_text.carico_12_potenza'))|int(default=0) > 5 111 | %} 112 | {{state_attr(states('input_text.carico_12_potenza'),'friendly_name')}}: 113 | {{states(states('input_text.carico_12_potenza')) }} W 114 | 115 | {%endif%} {%if 116 | states(states('input_text.carico_13_potenza'))|int(default=0) > 5 117 | %} 118 | {{state_attr(states('input_text.carico_13_potenza'),'friendly_name')}}: 119 | {{states(states('input_text.carico_13_potenza')) }} W 120 | 121 | {%endif%} {%if 122 | states(states('input_text.carico_14_potenza'))|int(default=0) > 5 123 | %} 124 | {{state_attr(states('input_text.carico_14_potenza'),'friendly_name')}}: 125 | {{states(states('input_text.carico_14_potenza')) }} W 126 | 127 | {%endif%} {%if 128 | states(states('input_text.carico_15_potenza'))|int(default=0) > 5 129 | %} 130 | {{state_attr(states('input_text.carico_15_potenza'),'friendly_name')}}: 131 | {{states(states('input_text.carico_15_potenza')) }} W 132 | 133 | {%endif%} {%if 134 | states(states('input_text.carico_16_potenza'))|int(default=0) > 5 135 | %} 136 | {{state_attr(states('input_text.carico_16_potenza'),'friendly_name')}}: 137 | {{states(states('input_text.carico_16_potenza')) }} W 138 | 139 | {%endif%} {%if 140 | states(states('input_text.carico_17_potenza'))|int(default=0) > 5 141 | %} 142 | {{state_attr(states('input_text.carico_17_potenza'),'friendly_name')}}: 143 | {{states(states('input_text.carico_17_potenza')) }} W 144 | 145 | {%endif%} {%if 146 | states(states('input_text.carico_18_potenza'))|int(default=0) > 5 147 | %} 148 | {{state_attr(states('input_text.carico_18_potenza'),'friendly_name')}}: 149 | {{states(states('input_text.carico_18_potenza')) }} W 150 | 151 | {%endif%} {%if 152 | states(states('input_text.carico_19_potenza'))|int(default=0) > 5 153 | %} 154 | {{state_attr(states('input_text.carico_19_potenza'),'friendly_name')}}: 155 | {{states(states('input_text.carico_19_potenza')) }} W 156 | 157 | {%endif%} {%if 158 | states(states('input_text.carico_20_potenza'))|int(default=0) > 5 159 | %} 160 | {{state_attr(states('input_text.carico_20_potenza'),'friendly_name')}}: 161 | {{states(states('input_text.carico_20_potenza')) }} W 162 | 163 | {%endif%} 164 | title: Carichi in uso 165 | - type: conditional 166 | conditions: 167 | - condition: or 168 | conditions: 169 | - condition: state 170 | entity: input_number.potenza_1_sospesa 171 | state_not: "0.0" 172 | - condition: state 173 | entity: input_number.potenza_2_sospesa 174 | state_not: "0.0" 175 | - condition: state 176 | entity: input_number.potenza_3_sospesa 177 | state_not: "0.0" 178 | - condition: state 179 | entity: input_number.potenza_4_sospesa 180 | state_not: "0.0" 181 | - condition: state 182 | entity: input_number.potenza_5_sospesa 183 | state_not: "0.0" 184 | - condition: state 185 | entity: input_number.potenza_6_sospesa 186 | state_not: "0.0" 187 | - condition: state 188 | entity: input_number.potenza_7_sospesa 189 | state_not: "0.0" 190 | - condition: state 191 | entity: input_number.potenza_8_sospesa 192 | state_not: "0.0" 193 | - condition: state 194 | entity: input_number.potenza_9_sospesa 195 | state_not: "0.0" 196 | - condition: state 197 | entity: input_number.potenza_10_sospesa 198 | state_not: "0.0" 199 | - condition: state 200 | entity: input_number.potenza_11_sospesa 201 | state_not: "0.0" 202 | - condition: state 203 | entity: input_number.potenza_12_sospesa 204 | state_not: "0.0" 205 | - condition: state 206 | entity: input_number.potenza_13_sospesa 207 | state_not: "0.0" 208 | - condition: state 209 | entity: input_number.potenza_14_sospesa 210 | state_not: "0.0" 211 | - condition: state 212 | entity: input_number.potenza_15_sospesa 213 | state_not: "0.0" 214 | - condition: state 215 | entity: input_number.potenza_16_sospesa 216 | state_not: "0.0" 217 | - condition: state 218 | entity: input_number.potenza_17_sospesa 219 | state_not: "0.0" 220 | - condition: state 221 | entity: input_number.potenza_18_sospesa 222 | state_not: "0.0" 223 | - condition: state 224 | entity: input_number.potenza_19_sospesa 225 | state_not: "0.0" 226 | - condition: state 227 | entity: input_number.potenza_20_sospesa 228 | state_not: "0.0" 229 | card: 230 | type: markdown 231 | content: >- 232 | {%if states('input_number.potenza_1_sospesa')|int(default=0) > 0 233 | %}{{ 234 | state_attr(states('input_text.carico_1_switch'),'friendly_name') 235 | }}: {{states('input_number.potenza_1_sospesa')|int}} W{%endif%} 236 | 237 | {%if states('input_number.potenza_2_sospesa')|int(default=0) > 0 238 | %}{{ 239 | state_attr(states('input_text.carico_2_switch'),'friendly_name') 240 | }}: {{states('input_number.potenza_2_sospesa')|int}} W{%endif%} 241 | 242 | {%if states('input_number.potenza_3_sospesa')|int(default=0) > 0 243 | %}{{ 244 | state_attr(states('input_text.carico_3_switch'),'friendly_name') 245 | }}: {{states('input_number.potenza_3_sospesa')|int}} W{%endif%} 246 | 247 | {%if states('input_number.potenza_4_sospesa')|int(default=0) > 0 248 | %}{{ 249 | state_attr(states('input_text.carico_4_switch'),'friendly_name') 250 | }}: {{states('input_number.potenza_4_sospesa')|int}} W{%endif%} 251 | 252 | {%if states('input_number.potenza_5_sospesa')|int(default=0) > 0 253 | %}{{ 254 | state_attr(states('input_text.carico_5_switch'),'friendly_name') 255 | }}: {{states('input_number.potenza_5_sospesa')|int}} W{%endif%} 256 | 257 | {%if states('input_number.potenza_6_sospesa')|int(default=0) > 0 258 | %}{{ 259 | state_attr(states('input_text.carico_6_switch'),'friendly_name') 260 | }}: {{states('input_number.potenza_6_sospesa')|int}} W{%endif%} 261 | 262 | {%if states('input_number.potenza_7_sospesa')|int(default=0) > 0 263 | %}{{ 264 | state_attr(states('input_text.carico_7_switch'),'friendly_name') 265 | }}: {{states('input_number.potenza_7_sospesa')|int}} W{%endif%} 266 | 267 | {%if states('input_number.potenza_8_sospesa')|int(default=0) > 0 268 | %}{{ 269 | state_attr(states('input_text.carico_8_switch'),'friendly_name') 270 | }}: {{states('input_number.potenza_8_sospesa')|int}} W{%endif%} 271 | 272 | {%if states('input_number.potenza_9_sospesa')|int(default=0) > 0 273 | %}{{ 274 | state_attr(states('input_text.carico_9_switch'),'friendly_name') 275 | }}: {{states('input_number.potenza_9_sospesa')|int}} W{%endif%} 276 | 277 | {%if states('input_number.potenza_10_sospesa')|int(default=0) > 278 | 0 %}{{ 279 | state_attr(states('input_text.carico_10_switch'),'friendly_name') 280 | }}: {{states('input_number.potenza_10_sospesa')|int}} W{%endif%} 281 | 282 | {%if states('input_number.potenza_11_sospesa')|int(default=0) > 283 | 0 %}{{ 284 | state_attr(states('input_text.carico_11_switch'),'friendly_name') 285 | }}: {{states('input_number.potenza_11_sospesa')|int}} W{%endif%} 286 | 287 | {%if states('input_number.potenza_12_sospesa')|int(default=0) > 288 | 0 %}{{ 289 | state_attr(states('input_text.carico_12_switch'),'friendly_name') 290 | }}: {{states('input_number.potenza_12_sospesa')|int}} W{%endif%} 291 | 292 | {%if states('input_number.potenza_13_sospesa')|int(default=0) > 293 | 0 %}{{ 294 | state_attr(states('input_text.carico_13_switch'),'friendly_name') 295 | }}: {{states('input_number.potenza_13_sospesa')|int}} W{%endif%} 296 | 297 | {%if states('input_number.potenza_14_sospesa')|int(default=0) > 298 | 0 %}{{ 299 | state_attr(states('input_text.carico_14_switch'),'friendly_name') 300 | }}: {{states('input_number.potenza_14_sospesa')|int}} W{%endif%} 301 | 302 | {%if states('input_number.potenza_15_sospesa')|int(default=0) > 303 | 0 %}{{ 304 | state_attr(states('input_text.carico_15_switch'),'friendly_name') 305 | }}: {{states('input_number.potenza_15_sospesa')|int}} W{%endif%} 306 | 307 | {%if states('input_number.potenza_16_sospesa')|int(default=0) > 308 | 0 %}{{ 309 | state_attr(states('input_text.carico_16_switch'),'friendly_name') 310 | }}: {{states('input_number.potenza_16_sospesa')|int}} W{%endif%} 311 | 312 | {%if states('input_number.potenza_17_sospesa')|int(default=0) > 313 | 0 %}{{ 314 | state_attr(states('input_text.carico_17_switch'),'friendly_name') 315 | }}: {{states('input_number.potenza_17_sospesa')|int}} W{%endif%} 316 | 317 | {%if states('input_number.potenza_18_sospesa')|int(default=0) > 318 | 0 %}{{ 319 | state_attr(states('input_text.carico_18_switch'),'friendly_name') 320 | }}: {{states('input_number.potenza_18_sospesa')|int}} W{%endif%} 321 | 322 | {%if states('input_number.potenza_19_sospesa')|int(default=0) > 323 | 0 %}{{ 324 | state_attr(states('input_text.carico_19_switch'),'friendly_name') 325 | }}: {{states('input_number.potenza_19_sospesa')|int}} W{%endif%} 326 | 327 | {%if states('input_number.potenza_20_sospesa')|int(default=0) > 328 | 0 %}{{ 329 | state_attr(states('input_text.carico_20_switch'),'friendly_name') 330 | }}: {{states('input_number.potenza_20_sospesa')|int}} W{%endif%} 331 | title: Sospesi 332 | - type: conditional 333 | conditions: 334 | - entity: input_boolean.impostazioni_power_control 335 | state: "on" 336 | card: 337 | type: markdown 338 | content: > 339 | Questa è la configurazione attualmente utilizzata, modificabile 340 | tramite i menu a discesa seguenti. 341 | 342 | 343 | **Sensore rilevamento potenza**: 344 | {{states('input_text.potenza_carichi')}} 345 | 346 | 347 | **Carico 1**: 348 | 349 | **Potenza**: {{states('input_text.carico_1_potenza')}} 350 | 351 | **Interruttore**: {{states('input_text.carico_1_switch')}} 352 | 353 | **Carico 2**: 354 | 355 | **Potenza**: {{states('input_text.carico_2_potenza')}} 356 | 357 | **Interruttore**: {{states('input_text.carico_2_switch')}} 358 | 359 | **Carico 3**: 360 | 361 | **Potenza**: {{states('input_text.carico_3_potenza')}} 362 | 363 | **Interruttore**: {{states('input_text.carico_3_switch')}} 364 | 365 | **Carico 4**: 366 | 367 | **Potenza**: {{states('input_text.carico_4_potenza')}} 368 | 369 | **Interruttore**: {{states('input_text.carico_4_switch')}} 370 | 371 | **Carico 5**: 372 | 373 | **Potenza**: {{states('input_text.carico_5_potenza')}} 374 | 375 | **Interruttore**: {{states('input_text.carico_5_switch')}} 376 | 377 | **Carico 6**: 378 | 379 | **Potenza**: {{states('input_text.carico_6_potenza')}} 380 | 381 | **Interruttore**: {{states('input_text.carico_6_switch')}} 382 | 383 | **Carico 7**: 384 | 385 | **Potenza**: {{states('input_text.carico_7_potenza')}} 386 | 387 | **Interruttore**: {{states('input_text.carico_7_switch')}} 388 | 389 | **Carico 8**: 390 | 391 | **Potenza**: {{states('input_text.carico_8_potenza')}} 392 | 393 | **Interruttore**: {{states('input_text.carico_8_switch')}} 394 | 395 | **Carico 9**: 396 | 397 | **Potenza**: {{states('input_text.carico_9_potenza')}} 398 | 399 | **Interruttore**: {{states('input_text.carico_9_switch')}} 400 | 401 | **Carico 10**: 402 | 403 | **Potenza**: {{states('input_text.carico_10_potenza')}} 404 | 405 | **Interruttore**: {{states('input_text.carico_10_switch')}} 406 | 407 | **Carico 11**: 408 | 409 | **Potenza**: {{states('input_text.carico_11_potenza')}} 410 | 411 | **Interruttore**: {{states('input_text.carico_11_switch')}} 412 | 413 | **Carico 12**: 414 | 415 | **Potenza**: {{states('input_text.carico_12_potenza')}} 416 | 417 | **Interruttore**: {{states('input_text.carico_12_switch')}} 418 | 419 | **Carico 13**: 420 | 421 | **Potenza**: {{states('input_text.carico_13_potenza')}} 422 | 423 | **Interruttore**: {{states('input_text.carico_13_switch')}} 424 | 425 | **Carico 14**: 426 | 427 | **Potenza**: {{states('input_text.carico_14_potenza')}} 428 | 429 | **Interruttore**: {{states('input_text.carico_14_switch')}} 430 | 431 | **Carico 15**: 432 | 433 | **Potenza**: {{states('input_text.carico_15_potenza')}} 434 | 435 | **Interruttore**: {{states('input_text.carico_15_switch')}} 436 | 437 | **Carico 16**: 438 | 439 | **Potenza**: {{states('input_text.carico_16_potenza')}} 440 | 441 | **Interruttore**: {{states('input_text.carico_16_switch')}} 442 | 443 | **Carico 17**: 444 | 445 | **Potenza**: {{states('input_text.carico_17_potenza')}} 446 | 447 | **Interruttore**: {{states('input_text.carico_17_switch')}} 448 | 449 | **Carico 18**: 450 | 451 | **Potenza**: {{states('input_text.carico_18_potenza')}} 452 | 453 | **Interruttore**: {{states('input_text.carico_18_switch')}} 454 | 455 | **Carico 19**: 456 | 457 | **Potenza**: {{states('input_text.carico_19_potenza')}} 458 | 459 | **Interruttore**: {{states('input_text.carico_19_switch')}} 460 | 461 | **Carico 20**: 462 | 463 | **Potenza**: {{states('input_text.carico_20_potenza')}} 464 | 465 | **Interruttore**: {{states('input_text.carico_20_switch')}} 466 | title: Configurazione Salvata 467 | - type: conditional 468 | conditions: 469 | - entity: input_boolean.impostazioni_power_control 470 | state: "on" 471 | card: 472 | type: vertical-stack 473 | cards: 474 | - type: markdown 475 | content: > 476 | **--> CLICCARE SU SALVA CONFIGURAZIONE DOPO AVER CONFIGURATO IL 477 | PACKAGE <--** 478 | 479 | 480 | **Sensore potenza carichi** 481 | 482 | Selezionare il sensore del consumo istantaneo globale. Se non 483 | disponibile, è possibile selezionare il sensore 484 | "sensor.potenza_carichi_virtuale" che è la somma della potenza 485 | utilizzata dai carichi inseriti nei campi sottostanti. 486 | 487 | 488 | **Potenza Massima Ritardato** 489 | 490 | Se l'assorbimento totale supera questa soglia, il sistema attende 491 | alcuni MINUTI (vedi opzione seguente) poi inizia a staccare i 492 | carichi. (suggerito 3200) 493 | 494 | 495 | **Minuti distacco ritardato** 496 | 497 | Dopo tot MINUTI di superamento della potenza massima RITARDATO, 498 | inizia il distacco. (suggerito 170) 499 | 500 | 501 | **Potenza Massima Immediato** 502 | 503 | Se l'assorbimento totale supera questa soglia, il sistema attende 504 | alcuni SECONDI (vedi opzione seguente) poi inizia a staccare i 505 | carichi. (suggerito 3900) 506 | 507 | 508 | **Secondi distacco immediato** 509 | 510 | Dopo tot SECONDI di superamento della potenza massima IMMEDIATO, 511 | inizia il distacco. (suggerito 10) 512 | 513 | 514 | **Minuti riattivazione** 515 | 516 | Dopo tot MINUTI che la potenza utilizzata è rientrata nei limiti, 517 | inizia a riattivare i carichi. (suggerito 5) 518 | 519 | 520 | **Secondi tra gli Stop** 521 | 522 | Attende tot SECONDI tra un distacco e l'altro. (suggerito 20) 523 | 524 | 525 | **Minuti tra gli Start** 526 | 527 | Attende tot MINUTI tra una riattivazione e l'altra per dare il tempo 528 | al carico di riprendere il suo normale assorbimento. (suggerito 5) 529 | 530 | 531 | **Nuova modalità selezione** 532 | 533 | Attivando questa opzione, le entità dei carichi verranno filtrate e 534 | saranno visibili solo quelle che iniziano con "sensor.potenza" e 535 | "swtich.interruttore". 536 | title: Configurazione 537 | - type: entities 538 | entities: 539 | - entity: input_select.potenza_carichi 540 | icon: hass:chart-line 541 | - entity: input_number.potenza_massima_ritardato 542 | name: Potenza Massima Ritardato 543 | icon: hass:chart-bell-curve 544 | - entity: input_number.tempo_stop_ritardato 545 | name: Minuti distacco ritardato 546 | icon: hass:camera-timer 547 | - entity: input_number.potenza_massima_immediato 548 | name: Potenza Massima Immediato 549 | icon: hass:chart-bell-curve 550 | - entity: input_number.tempo_stop_immediato 551 | name: Secondi distacco immediato 552 | icon: hass:camera-timer 553 | - entity: input_number.tempo_start 554 | name: Minuti riattivazione 555 | icon: hass:camera-timer 556 | - entity: input_number.attesa_stop 557 | name: Secondi tra gli stop 558 | icon: hass:camera-timer 559 | - entity: input_number.attesa_start 560 | name: Minuti tra gli start 561 | icon: hass:camera-timer 562 | - entity: input_boolean.selezione_script_python 563 | name: Nuova modalità selezione opzioni 564 | state_color: true 565 | show_header_toggle: false 566 | - type: conditional 567 | conditions: 568 | - entity: input_boolean.impostazioni_power_control 569 | state: "on" 570 | card: 571 | type: vertical-stack 572 | cards: 573 | - type: markdown 574 | content: >- 575 | **Sensore Carichi** 576 | 577 | Selezionare i sensori di potenza (W) dei carichi da monitorare e 578 | scollegare in caso di eccessiva richiesta. 579 | - type: entities 580 | entities: 581 | - entity: input_select.carico_1_potenza 582 | - entity: input_select.carico_2_potenza 583 | - entity: input_select.carico_3_potenza 584 | - entity: input_select.carico_4_potenza 585 | - entity: input_select.carico_5_potenza 586 | - entity: input_select.carico_6_potenza 587 | - entity: input_select.carico_7_potenza 588 | - entity: input_select.carico_8_potenza 589 | - entity: input_select.carico_9_potenza 590 | - entity: input_select.carico_10_potenza 591 | - entity: input_select.carico_11_potenza 592 | - entity: input_select.carico_12_potenza 593 | - entity: input_select.carico_13_potenza 594 | - entity: input_select.carico_14_potenza 595 | - entity: input_select.carico_15_potenza 596 | - entity: input_select.carico_16_potenza 597 | - entity: input_select.carico_17_potenza 598 | - entity: input_select.carico_18_potenza 599 | - entity: input_select.carico_19_potenza 600 | - entity: input_select.carico_20_potenza 601 | title: Sensori potenza carichi 602 | - type: conditional 603 | conditions: 604 | - entity: input_boolean.impostazioni_power_control 605 | state: "on" 606 | card: 607 | type: vertical-stack 608 | cards: 609 | - type: markdown 610 | content: >- 611 | **Interruttori Carichi** 612 | 613 | Selezionare gli switch relativi ai carichi monitorati nel 614 | corrispettivo sensore. I carichi verrrano scollegati in ordine di 615 | priorità inversa, **a partire dal Carico 20** fino al Carico 1, solo 616 | se la potenza che sono in uso. Dopo che la richiesta di potenza 617 | rientra nei limiti, i carichi scollegati in precedenza, verranno 618 | progressivamente ricollegati **a partire dal Carico 1** fino al 619 | Carico 30. 620 | 621 | L'opzione **Mantieni spento Carico** permette di NON riattivare il 622 | carico in caso venga spento per superamenteo dei limiti. Il carico 623 | andrà dunque riattivato manualmente. 624 | - type: entities 625 | entities: 626 | - entity: input_select.carico_1_switch 627 | - entity: input_boolean.mantini_spento_1 628 | name: Mantieni spento 629 | - entity: input_select.carico_2_switch 630 | - entity: input_boolean.mantini_spento_2 631 | name: Mantieni spento 632 | - entity: input_select.carico_3_switch 633 | - entity: input_boolean.mantini_spento_3 634 | name: Mantieni spento 635 | - entity: input_select.carico_4_switch 636 | - entity: input_boolean.mantini_spento_4 637 | name: Mantieni spento 638 | - entity: input_select.carico_5_switch 639 | - entity: input_boolean.mantini_spento_5 640 | name: Mantieni spento 641 | - entity: input_select.carico_6_switch 642 | - entity: input_boolean.mantini_spento_6 643 | name: Mantieni spento 644 | - entity: input_select.carico_7_switch 645 | - entity: input_boolean.mantini_spento_7 646 | name: Mantieni spento 647 | - entity: input_select.carico_8_switch 648 | - entity: input_boolean.mantini_spento_8 649 | name: Mantieni spento 650 | - entity: input_select.carico_9_switch 651 | - entity: input_boolean.mantini_spento_9 652 | name: Mantieni spento 653 | - entity: input_select.carico_10_switch 654 | - entity: input_boolean.mantini_spento_10 655 | name: Mantieni spento 656 | - entity: input_select.carico_11_switch 657 | - entity: input_boolean.mantini_spento_11 658 | name: Mantieni spento 659 | - entity: input_select.carico_12_switch 660 | - entity: input_boolean.mantini_spento_12 661 | name: Mantieni spento 662 | - entity: input_select.carico_13_switch 663 | - entity: input_boolean.mantini_spento_13 664 | name: Mantieni spento 665 | - entity: input_select.carico_14_switch 666 | - entity: input_boolean.mantini_spento_14 667 | name: Mantieni spento 668 | - entity: input_select.carico_15_switch 669 | - entity: input_boolean.mantini_spento_15 670 | name: Mantieni spento 671 | - entity: input_select.carico_16_switch 672 | - entity: input_boolean.mantini_spento_16 673 | name: Mantieni spento 674 | - entity: input_select.carico_17_switch 675 | - entity: input_boolean.mantini_spento_17 676 | name: Mantieni spento 677 | - entity: input_select.carico_18_switch 678 | - entity: input_boolean.mantini_spento_18 679 | name: Mantieni spento 680 | - entity: input_select.carico_19_switch 681 | - entity: input_boolean.mantini_spento_19 682 | name: Mantieni spento 683 | - entity: input_select.carico_20_switch 684 | - entity: input_boolean.mantini_spento_20 685 | name: Mantieni spento 686 | title: Interruttori Carichi 687 | show_header_toggle: false 688 | -------------------------------------------------------------------------------- /python_scripts/update_entities.py: -------------------------------------------------------------------------------- 1 | #group_entities = hass.states.get('group.all_lights').attributes['entity_id'] 2 | #all_lights = [] 3 | #for e in group_entities: 4 | # all_lights.append(e) 5 | #service_data = {'entity_id': 'input_select.timer_generico7', 6 | # 'options': all_lights} 7 | #hass.services.call('input_select', 'set_options', service_data) 8 | 9 | 10 | #group_entities = hass.states.get('group.all_lights').attributes['entity_id'] 11 | #all_lights = [] 12 | #for e in group_entities: 13 | # all_lights.append(hass.states.get(e).attributes['friendly_name']) 14 | #service_data = {'entity_id': 'input_select.timer_generico7', 15 | # 'options': all_lights} 16 | #hass.services.call('input_select', 'set_options', service_data) 17 | 18 | 19 | #entities = hass.states.entity_ids() 20 | #service_data = {'entity_id': 'input_select.entities', 'options': sorted(entities)} 21 | #hass.services.call('input_select', 'set_options', service_data) 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | entities = hass.states.entity_ids('switch') 30 | all_switches = ["Seleziona"] 31 | for e in entities: 32 | all_switches.append(e) 33 | 34 | entities = hass.states.entity_ids('light') 35 | for e in entities: 36 | all_switches.append(e) 37 | 38 | 39 | service_data = {'entity_id': 'input_select.carico_1_switch', 'options': sorted(all_switches)} 40 | hass.services.call('input_select', 'set_options', service_data) 41 | service_data = {'entity_id': 'input_select.carico_2_switch', 'options': sorted(all_switches)} 42 | hass.services.call('input_select', 'set_options', service_data) 43 | service_data = {'entity_id': 'input_select.carico_3_switch', 'options': sorted(all_switches)} 44 | hass.services.call('input_select', 'set_options', service_data) 45 | service_data = {'entity_id': 'input_select.carico_4_switch', 'options': sorted(all_switches)} 46 | hass.services.call('input_select', 'set_options', service_data) 47 | service_data = {'entity_id': 'input_select.carico_5_switch', 'options': sorted(all_switches)} 48 | hass.services.call('input_select', 'set_options', service_data) 49 | service_data = {'entity_id': 'input_select.carico_6_switch', 'options': sorted(all_switches)} 50 | hass.services.call('input_select', 'set_options', service_data) 51 | service_data = {'entity_id': 'input_select.carico_7_switch', 'options': sorted(all_switches)} 52 | hass.services.call('input_select', 'set_options', service_data) 53 | service_data = {'entity_id': 'input_select.carico_8_switch', 'options': sorted(all_switches)} 54 | hass.services.call('input_select', 'set_options', service_data) 55 | service_data = {'entity_id': 'input_select.carico_9_switch', 'options': sorted(all_switches)} 56 | hass.services.call('input_select', 'set_options', service_data) 57 | service_data = {'entity_id': 'input_select.carico_10_switch', 'options': sorted(all_switches)} 58 | hass.services.call('input_select', 'set_options', service_data) 59 | service_data = {'entity_id': 'input_select.carico_11_switch', 'options': sorted(all_switches)} 60 | hass.services.call('input_select', 'set_options', service_data) 61 | service_data = {'entity_id': 'input_select.carico_12_switch', 'options': sorted(all_switches)} 62 | hass.services.call('input_select', 'set_options', service_data) 63 | service_data = {'entity_id': 'input_select.carico_13_switch', 'options': sorted(all_switches)} 64 | hass.services.call('input_select', 'set_options', service_data) 65 | service_data = {'entity_id': 'input_select.carico_14_switch', 'options': sorted(all_switches)} 66 | hass.services.call('input_select', 'set_options', service_data) 67 | service_data = {'entity_id': 'input_select.carico_15_switch', 'options': sorted(all_switches)} 68 | hass.services.call('input_select', 'set_options', service_data) 69 | service_data = {'entity_id': 'input_select.carico_16_switch', 'options': sorted(all_switches)} 70 | hass.services.call('input_select', 'set_options', service_data) 71 | service_data = {'entity_id': 'input_select.carico_17_switch', 'options': sorted(all_switches)} 72 | hass.services.call('input_select', 'set_options', service_data) 73 | service_data = {'entity_id': 'input_select.carico_18_switch', 'options': sorted(all_switches)} 74 | hass.services.call('input_select', 'set_options', service_data) 75 | service_data = {'entity_id': 'input_select.carico_19_switch', 'options': sorted(all_switches)} 76 | hass.services.call('input_select', 'set_options', service_data) 77 | service_data = {'entity_id': 'input_select.carico_20_switch', 'options': sorted(all_switches)} 78 | hass.services.call('input_select', 'set_options', service_data) 79 | 80 | entities = hass.states.entity_ids('sensor') 81 | all_sensor = ["Seleziona"] 82 | for e in entities: 83 | all_sensor.append(e) 84 | 85 | service_data = {'entity_id': 'input_select.carico_1_potenza', 'options': sorted(all_sensor)} 86 | hass.services.call('input_select', 'set_options', service_data) 87 | service_data = {'entity_id': 'input_select.carico_2_potenza', 'options': sorted(all_sensor)} 88 | hass.services.call('input_select', 'set_options', service_data) 89 | service_data = {'entity_id': 'input_select.carico_3_potenza', 'options': sorted(all_sensor)} 90 | hass.services.call('input_select', 'set_options', service_data) 91 | service_data = {'entity_id': 'input_select.carico_4_potenza', 'options': sorted(all_sensor)} 92 | hass.services.call('input_select', 'set_options', service_data) 93 | service_data = {'entity_id': 'input_select.carico_5_potenza', 'options': sorted(all_sensor)} 94 | hass.services.call('input_select', 'set_options', service_data) 95 | service_data = {'entity_id': 'input_select.carico_6_potenza', 'options': sorted(all_sensor)} 96 | hass.services.call('input_select', 'set_options', service_data) 97 | service_data = {'entity_id': 'input_select.carico_7_potenza', 'options': sorted(all_sensor)} 98 | hass.services.call('input_select', 'set_options', service_data) 99 | service_data = {'entity_id': 'input_select.carico_8_potenza', 'options': sorted(all_sensor)} 100 | hass.services.call('input_select', 'set_options', service_data) 101 | service_data = {'entity_id': 'input_select.carico_9_potenza', 'options': sorted(all_sensor)} 102 | hass.services.call('input_select', 'set_options', service_data) 103 | service_data = {'entity_id': 'input_select.carico_10_potenza', 'options': sorted(all_sensor)} 104 | hass.services.call('input_select', 'set_options', service_data) 105 | service_data = {'entity_id': 'input_select.carico_11_potenza', 'options': sorted(all_sensor)} 106 | hass.services.call('input_select', 'set_options', service_data) 107 | service_data = {'entity_id': 'input_select.carico_12_potenza', 'options': sorted(all_sensor)} 108 | hass.services.call('input_select', 'set_options', service_data) 109 | service_data = {'entity_id': 'input_select.carico_13_potenza', 'options': sorted(all_sensor)} 110 | hass.services.call('input_select', 'set_options', service_data) 111 | service_data = {'entity_id': 'input_select.carico_14_potenza', 'options': sorted(all_sensor)} 112 | hass.services.call('input_select', 'set_options', service_data) 113 | service_data = {'entity_id': 'input_select.carico_15_potenza', 'options': sorted(all_sensor)} 114 | hass.services.call('input_select', 'set_options', service_data) 115 | service_data = {'entity_id': 'input_select.carico_16_potenza', 'options': sorted(all_sensor)} 116 | hass.services.call('input_select', 'set_options', service_data) 117 | service_data = {'entity_id': 'input_select.carico_17_potenza', 'options': sorted(all_sensor)} 118 | hass.services.call('input_select', 'set_options', service_data) 119 | service_data = {'entity_id': 'input_select.carico_18_potenza', 'options': sorted(all_sensor)} 120 | hass.services.call('input_select', 'set_options', service_data) 121 | service_data = {'entity_id': 'input_select.carico_19_potenza', 'options': sorted(all_sensor)} 122 | hass.services.call('input_select', 'set_options', service_data) 123 | service_data = {'entity_id': 'input_select.carico_20_potenza', 'options': sorted(all_sensor)} 124 | hass.services.call('input_select', 'set_options', service_data) 125 | 126 | service_data = {'entity_id': 'input_select.potenza_carichi', 'options': sorted(all_sensor)} 127 | hass.services.call('input_select', 'set_options', service_data) 128 | -------------------------------------------------------------------------------- /python_scripts/update_entities_new.py: -------------------------------------------------------------------------------- 1 | entities = hass.states.entity_ids('switch') 2 | all_switches = ["Seleziona"] 3 | for e in entities: 4 | if e.startswith("switch.interruttore") : all_switches.append(e) 5 | 6 | #entities = hass.states.entity_ids('switch') 7 | #all_switches = ["Seleziona"] 8 | #for e in entities: 9 | # all_switches.append(e) 10 | 11 | service_data = {'entity_id': 'input_select.carico_1_switch', 'options': sorted(all_switches)} 12 | hass.services.call('input_select', 'set_options', service_data) 13 | service_data = {'entity_id': 'input_select.carico_2_switch', 'options': sorted(all_switches)} 14 | hass.services.call('input_select', 'set_options', service_data) 15 | service_data = {'entity_id': 'input_select.carico_3_switch', 'options': sorted(all_switches)} 16 | hass.services.call('input_select', 'set_options', service_data) 17 | service_data = {'entity_id': 'input_select.carico_4_switch', 'options': sorted(all_switches)} 18 | hass.services.call('input_select', 'set_options', service_data) 19 | service_data = {'entity_id': 'input_select.carico_5_switch', 'options': sorted(all_switches)} 20 | hass.services.call('input_select', 'set_options', service_data) 21 | service_data = {'entity_id': 'input_select.carico_6_switch', 'options': sorted(all_switches)} 22 | hass.services.call('input_select', 'set_options', service_data) 23 | service_data = {'entity_id': 'input_select.carico_7_switch', 'options': sorted(all_switches)} 24 | hass.services.call('input_select', 'set_options', service_data) 25 | service_data = {'entity_id': 'input_select.carico_8_switch', 'options': sorted(all_switches)} 26 | hass.services.call('input_select', 'set_options', service_data) 27 | service_data = {'entity_id': 'input_select.carico_9_switch', 'options': sorted(all_switches)} 28 | hass.services.call('input_select', 'set_options', service_data) 29 | service_data = {'entity_id': 'input_select.carico_10_switch', 'options': sorted(all_switches)} 30 | hass.services.call('input_select', 'set_options', service_data) 31 | service_data = {'entity_id': 'input_select.carico_11_switch', 'options': sorted(all_switches)} 32 | hass.services.call('input_select', 'set_options', service_data) 33 | service_data = {'entity_id': 'input_select.carico_12_switch', 'options': sorted(all_switches)} 34 | hass.services.call('input_select', 'set_options', service_data) 35 | service_data = {'entity_id': 'input_select.carico_13_switch', 'options': sorted(all_switches)} 36 | hass.services.call('input_select', 'set_options', service_data) 37 | service_data = {'entity_id': 'input_select.carico_14_switch', 'options': sorted(all_switches)} 38 | hass.services.call('input_select', 'set_options', service_data) 39 | service_data = {'entity_id': 'input_select.carico_15_switch', 'options': sorted(all_switches)} 40 | hass.services.call('input_select', 'set_options', service_data) 41 | service_data = {'entity_id': 'input_select.carico_16_switch', 'options': sorted(all_switches)} 42 | hass.services.call('input_select', 'set_options', service_data) 43 | service_data = {'entity_id': 'input_select.carico_17_switch', 'options': sorted(all_switches)} 44 | hass.services.call('input_select', 'set_options', service_data) 45 | service_data = {'entity_id': 'input_select.carico_18_switch', 'options': sorted(all_switches)} 46 | hass.services.call('input_select', 'set_options', service_data) 47 | service_data = {'entity_id': 'input_select.carico_19_switch', 'options': sorted(all_switches)} 48 | hass.services.call('input_select', 'set_options', service_data) 49 | service_data = {'entity_id': 'input_select.carico_20_switch', 'options': sorted(all_switches)} 50 | hass.services.call('input_select', 'set_options', service_data) 51 | 52 | entities = hass.states.entity_ids('sensor') 53 | all_sensor = ["Seleziona"] 54 | for e in entities: 55 | if e.startswith("sensor.potenza") : all_sensor.append(e) 56 | 57 | service_data = {'entity_id': 'input_select.carico_1_potenza', 'options': sorted(all_sensor)} 58 | hass.services.call('input_select', 'set_options', service_data) 59 | service_data = {'entity_id': 'input_select.carico_2_potenza', 'options': sorted(all_sensor)} 60 | hass.services.call('input_select', 'set_options', service_data) 61 | service_data = {'entity_id': 'input_select.carico_3_potenza', 'options': sorted(all_sensor)} 62 | hass.services.call('input_select', 'set_options', service_data) 63 | service_data = {'entity_id': 'input_select.carico_4_potenza', 'options': sorted(all_sensor)} 64 | hass.services.call('input_select', 'set_options', service_data) 65 | service_data = {'entity_id': 'input_select.carico_5_potenza', 'options': sorted(all_sensor)} 66 | hass.services.call('input_select', 'set_options', service_data) 67 | service_data = {'entity_id': 'input_select.carico_6_potenza', 'options': sorted(all_sensor)} 68 | hass.services.call('input_select', 'set_options', service_data) 69 | service_data = {'entity_id': 'input_select.carico_7_potenza', 'options': sorted(all_sensor)} 70 | hass.services.call('input_select', 'set_options', service_data) 71 | service_data = {'entity_id': 'input_select.carico_8_potenza', 'options': sorted(all_sensor)} 72 | hass.services.call('input_select', 'set_options', service_data) 73 | service_data = {'entity_id': 'input_select.carico_9_potenza', 'options': sorted(all_sensor)} 74 | hass.services.call('input_select', 'set_options', service_data) 75 | service_data = {'entity_id': 'input_select.carico_10_potenza', 'options': sorted(all_sensor)} 76 | hass.services.call('input_select', 'set_options', service_data) 77 | service_data = {'entity_id': 'input_select.carico_11_potenza', 'options': sorted(all_sensor)} 78 | hass.services.call('input_select', 'set_options', service_data) 79 | service_data = {'entity_id': 'input_select.carico_12_potenza', 'options': sorted(all_sensor)} 80 | hass.services.call('input_select', 'set_options', service_data) 81 | service_data = {'entity_id': 'input_select.carico_13_potenza', 'options': sorted(all_sensor)} 82 | hass.services.call('input_select', 'set_options', service_data) 83 | service_data = {'entity_id': 'input_select.carico_14_potenza', 'options': sorted(all_sensor)} 84 | hass.services.call('input_select', 'set_options', service_data) 85 | service_data = {'entity_id': 'input_select.carico_15_potenza', 'options': sorted(all_sensor)} 86 | hass.services.call('input_select', 'set_options', service_data) 87 | service_data = {'entity_id': 'input_select.carico_16_potenza', 'options': sorted(all_sensor)} 88 | hass.services.call('input_select', 'set_options', service_data) 89 | service_data = {'entity_id': 'input_select.carico_17_potenza', 'options': sorted(all_sensor)} 90 | hass.services.call('input_select', 'set_options', service_data) 91 | service_data = {'entity_id': 'input_select.carico_18_potenza', 'options': sorted(all_sensor)} 92 | hass.services.call('input_select', 'set_options', service_data) 93 | service_data = {'entity_id': 'input_select.carico_19_potenza', 'options': sorted(all_sensor)} 94 | hass.services.call('input_select', 'set_options', service_data) 95 | service_data = {'entity_id': 'input_select.carico_20_potenza', 'options': sorted(all_sensor)} 96 | hass.services.call('input_select', 'set_options', service_data) 97 | 98 | service_data = {'entity_id': 'input_select.potenza_carichi', 'options': sorted(all_sensor)} 99 | hass.services.call('input_select', 'set_options', service_data) 100 | --------------------------------------------------------------------------------