Skip to content

Commit 241c1f4

Browse files
2 parents a441b8f + 541944f commit 241c1f4

File tree

3 files changed

+158
-17
lines changed

3 files changed

+158
-17
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
11
# These are supported funding model platforms
2-
3-
github: [tomasmcguinness]
4-
patreon: # Replace with a single Patreon username
5-
open_collective: # Replace with a single Open Collective username
62
ko_fi: tomasmcguinness
7-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9-
liberapay: # Replace with a single Liberapay username
10-
issuehunt: # Replace with a single IssueHunt username
11-
otechie: # Replace with a single Otechie username
12-
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Add support for Mixergy's smart water tank into Home Assistant. This integration
88

99
## Support
1010

11-
If you use this integration, please consider buying me a coffee or beer as way of saying thanks https://ko-fi.com/tomasmcguinness
11+
If you want to support this project, please consider buying me a coffee!
12+
13+
<a href='https://ko-fi.com/G2G11TQK5' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi2.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
1214

1315
## Installation
1416

@@ -36,13 +38,40 @@ You then need to provide your Mixergy credentials and the serial number of your
3638

3739
This integration offers two services:
3840

39-
`mixergy.mixergy_set_charge` - It allows you to provide a target charge percentage.
40-
`mixergy.mixergy_set_target_temperature` - It allows you to set the target temperature of the water.
41-
`mixergy.mixergy_set_holiday_dates` - It allows you to set the holiday start and end dates.
42-
`mixergy.mixergy_clear_holiday_dates` - It allows you to clear the holiday dates.
41+
`mixergy.mixergy_set_charge` - This boosts the hot water to the desired percentage.
42+
`mixergy.mixergy_set_target_temperature` - Sets the desired hot water temperature.
43+
`mixergy.mixergy_set_holiday_dates` - Set the holiday mode start and end dates.
44+
`mixergy.mixergy_clear_holiday_dates` - Clears the holiday dates, taking the tank out of holiday mode.
45+
`mixergy_set_default_heat_source` - Changes the tank's default heat source.
4346

4447
![image](https://user-images.githubusercontent.com/302741/134326151-7e1583fe-f3b7-482f-82ab-016f2f662cb6.png)
4548

49+
## Lovelace Card
50+
51+
I has created a Love Lace card to give a visual representation of your Mixergy Tank.
52+
53+
![image](https://github.com/user-attachments/assets/fb46e762-0f34-4ed8-a7e2-6a02111e6903)
54+
55+
### Installation
56+
57+
To install this card, start by copying the `www/mixergy-card.js` file into your Home Assistant's `www` folder.
58+
59+
In Home Assistant, go to Settings > Dashboards. Click on the three-dot menu, in the rop right, and choose Resources.
60+
61+
Then click the "Add Resource" button.
62+
63+
Enter the URL as `/local/mixergy-card.js` and select `Javascript Module` as the Resource Type.
64+
65+
Click `Create`. You should then be able to add the Mixergy card into your dashboards.
66+
67+
```
68+
type: custom:mixergy-card
69+
entity_current_charge: sensor.mixergy_current_charge
70+
```
71+
72+
> [!TIP]
73+
> Watch the entity name in the snippet above. Also, you can only reference this card using YAML at this time. I want to find out how to deploy this card as a HACS package to make installation easier.
74+
4675
## Improvements
4776

4877
This integration is useful as it provides the state of your Mixergy tank via the API, but there are numerous enhancements I would like to make.
@@ -52,7 +81,8 @@ This integration is useful as it provides the state of your Mixergy tank via the
5281
* ~~Add a service to enable the charge to be set, so you can boost via HA~~
5382
* ~~Put better icons into the status~~
5483
* Ensure authentication token expiry is handled correctly. (Been told the token doesn't expire at present)
55-
* Create a nice Lovelace card that provides a visual representation of the tank's state.
84+
* ~~Create a nice Lovelace card that provides a visual representation of the tank's state.~~
85+
* Add the Card as a HACS package.
5686
* Get this component merged into the HomeAssistant core?
5787
* Update the Mixergy icon and support dark mode
5888
* ~~Get the Mixergy icon added, to improve the installation~~

www/mixergy-card.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import "https://unpkg.com/wired-card@0.8.1/wired-card.js?module";
2+
import "https://unpkg.com/wired-toggle@0.8.0/wired-toggle.js?module";
3+
import {
4+
LitElement,
5+
html,
6+
css
7+
} from "https://unpkg.com/lit-element@2.0.1/lit-element.js?module";
8+
9+
class MixergyCard extends LitElement {
10+
static get properties() {
11+
return {
12+
hass: {},
13+
config: {}
14+
};
15+
}
16+
17+
render() {
18+
return html`
19+
<ha-card header="Mixergy">
20+
<div class="content">
21+
<div class="tank">
22+
${html`
23+
<div class="hot-water" style="height: ${this.getHeight()}">
24+
</div>
25+
<div class="hot-water-percentage">
26+
${this.getPercentage()}
27+
</div>
28+
`}
29+
</div>
30+
</div>
31+
</ha-card>
32+
`;
33+
}
34+
35+
getPercentage() {
36+
let entity = this.config.entity_current_charge;
37+
let state = this.hass.states[entity];
38+
let percentage = parseFloat(state.state);
39+
return Math.floor(percentage) + "%";
40+
}
41+
42+
getHeight() {
43+
let entity = this.config.entity_current_charge;
44+
let state = this.hass.states[entity];
45+
let percentage = parseFloat(state.state) / 100;
46+
let height = Math.floor(300 * percentage);
47+
return height + "px";
48+
}
49+
50+
getOffset() {
51+
let entity = this.config.entity_current_charge;
52+
let state = this.hass.states[entity];
53+
let percentage = parseFloat(state.state) / 100;
54+
let size = Math.floor(300 - (300 * percentage));
55+
return size + 1 + "px";
56+
}
57+
58+
setConfig(config) {
59+
if (!config.entity_current_charge) {
60+
throw new Error("You need to define entities");
61+
}
62+
this.config = config;
63+
}
64+
65+
// The height of your card. Home Assistant uses this to automatically
66+
// distribute all cards over the available columns.
67+
getCardSize() {
68+
return 5;
69+
}
70+
71+
static get styles() {
72+
return css`
73+
ha-card {
74+
display: block;
75+
font-size: 18px;
76+
}
77+
78+
.content {
79+
display: flex;
80+
flex-direction: column;
81+
align-items: center;
82+
}
83+
84+
ha-card h1.card-header {
85+
align-self: start !important;
86+
}
87+
88+
.tank {
89+
background-color: #039be5;
90+
height: 300px;
91+
width: 120px;
92+
border-radius: 5px;
93+
margin-bottom: 20px;
94+
display: grid;
95+
}
96+
97+
.hot-water {
98+
align-self: flex-end;
99+
background-color: red;
100+
width: 120px;
101+
border-radius: 5px;
102+
align-items: center;
103+
justify-content: center;
104+
font-weight: bold;
105+
grid-row: 1;
106+
grid-column: 1;
107+
}
108+
109+
.hot-water-percentage {
110+
align-self: center;
111+
justify-self: center;
112+
text-align: center;
113+
font-weight: bold;
114+
font-size: large;
115+
grid-row: 1;
116+
grid-column: 1;
117+
}
118+
`;
119+
}
120+
}
121+
customElements.define("mixergy-card", MixergyCard);
122+
Advertisement

0 commit comments

Comments
 (0)