Home Assistant component for Mosaic Palette and Canvas Hub Octoprint plug-ins

$.ajax({
                url: API_BASEURL + "plugin/palette2",
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    command: "getPingHistory"
                }),
                contentType: "application/json; charset=UTF-8"
            }).done(function(data){console.log(data)});
1 Like

Fair enough. Cheers for that. Noob indeed, but trying. I'll look into it when back home... I'll try to contact @gdombi to see, we can get some input. Looked at the github for OctoPod, but no luck: https://github.com/gdombiak/OctoPod

OK, got it. I can see the pings as such:

{readyState: 1, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}
readyState: 4
getResponseHeader: ƒ ( key )
getAllResponseHeaders: ƒ ()
setRequestHeader: ƒ ( name, value )
overrideMimeType: ƒ ( type )
statusCode: ƒ ( map )
abort: ƒ ( statusText )
state: ƒ ()
always: ƒ ()
catch: ƒ ( fn )
pipe: ƒ ( /* fnDone, fnFail, fnProgress */ )
then: ƒ ( onFulfilled, onRejected, onProgress )
promise: ƒ ( obj )
progress: ƒ ()
done: ƒ ()
fail: ƒ ()
responseText: "{↵  "data": [↵    {↵      "number": 1, ↵      "per"
responseJSON:
data: Array(237)
[0 … 99]
0:
number: 1
percent: 96.74
__proto__: Object
1: {number: 2, percent: 99.04}
2: {number: 3, percent: 100.17}
3: {number: 4, percent: 99.41}
4: {number: 5, percent: 100.04}
5: {number: 6, percent: 100.84}
6: {number: 7, percent: 101.04}
7: {number: 8, percent: 100.38}
8: {number: 9, percent: 100.06}
9: {number: 10, percent: 100.13}
10: {number: 11, percent: 100.17}
11: {number: 12, percent: 100.37}
12: {number: 13, percent: 101.03}
13: {number: 14, percent: 100.97}
14: {number: 15, percent: 100.54}
15: {number: 16, percent: 100.38}
16: {number: 17, percent: 100.33}
17: {number: 18, percent: 100.51}
18: {number: 19, percent: 100.89}
19: {number: 20, percent: 101.27}
20: {number: 21, percent: 101.18}
21: {number: 22, percent: 101}
22: {number: 23, percent: 101.31}
23: {number: 24, percent: 101.48}
24: {number: 25, percent: 100.97}
25: {number: 26, percent: 100.96}
26: {number: 27, percent: 101.48}
27: {number: 28, percent: 101.57}
28: {number: 29, percent: 101.35}
29: {number: 30, percent: 101.36}
30: {number: 31, percent: 101.28}
31: {number: 32, percent: 101.24}
32: {number: 33, percent: 101.08}
33: {number: 34, percent: 101.25}
34: {number: 35, percent: 101.34}
35: {number: 36, percent: 101.14}
36: {number: 37, percent: 101.24}
37: {number: 38, percent: 101.24}
38: {number: 39, percent: 101.01}
39: {number: 40, percent: 101.1}
40: {number: 41, percent: 101.59}
41: {number: 42, percent: 101.8}
42: {number: 43, percent: 102.15}
43: {number: 44, percent: 101.9}
44: {number: 45, percent: 101.61}
45: {number: 46, percent: 101.51}
46: {number: 47, percent: 101.08}
47: {number: 48, percent: 101.04}
48: {number: 49, percent: 101.24}
49: {number: 50, percent: 101.06}
50: {number: 51, percent: 101.03}
51: {number: 52, percent: 101.15}
52: {number: 53, percent: 100.86}
53: {number: 54, percent: 100.99}
54: {number: 55, percent: 101.18}
55: {number: 56, percent: 101.74}
56: {number: 57, percent: 102.36}
57: {number: 58, percent: 102.24}
58: {number: 59, percent: 102.19}
59: {number: 60, percent: 102.04}
60: {number: 61, percent: 101.64}
61: {number: 62, percent: 101.05}
62: {number: 63, percent: 100.79}
63: {number: 64, percent: 100.53}
64: {number: 65, percent: 100.96}
65: {number: 66, percent: 100.92}
66: {number: 67, percent: 100.5}
67: {number: 68, percent: 101.14}
68: {number: 69, percent: 101.24}
69: {number: 70, percent: 100.94}
70: {number: 71, percent: 100.87}
71: {number: 72, percent: 101.23}
72: {number: 73, percent: 101.24}
73: {number: 74, percent: 100.98}
74: {number: 75, percent: 101.32}
75: {number: 76, percent: 101.29}
76: {number: 77, percent: 100.89}
77: {number: 78, percent: 100.92}
78: {number: 79, percent: 101.22}
79: {number: 80, percent: 101.28}
80: {number: 81, percent: 101.02}
81: {number: 82, percent: 101.33}
82: {number: 83, percent: 101.34}
83: {number: 84, percent: 101.1}
84: {number: 85, percent: 101.05}
85: {number: 86, percent: 101.25}
86: {number: 87, percent: 101.35}
87: {number: 88, percent: 101.03}
88: {number: 89, percent: 101.15}
89: {number: 90, percent: 101.21}
90: {number: 91, percent: 101}
91: {number: 92, percent: 101.05}
92: {number: 93, percent: 101.39}
93: {number: 94, percent: 101.39}
94: {number: 95, percent: 101.05}
95: {number: 96, percent: 101.27}
96: {number: 97, percent: 101.44}
97: {number: 98, percent: 101.07}
98: {number: 99, percent: 101.04}
99: {number: 100, percent: 101.3}
[100 … 199]
100: {number: 101, percent: 101.26}
101: {number: 102, percent: 101}
102: {number: 103, percent: 101.31}
103: {number: 104, percent: 101.42}
104: {number: 105, percent: 101.07}
105: {number: 106, percent: 101.08}
106: {number: 107, percent: 101.26}
107: {number: 108, percent: 101.22}
108: {number: 109, percent: 100.84}
109: {number: 110, percent: 101.2}
110: {number: 111, percent: 101.41}
111: {number: 112, percent: 101.13}
112: {number: 113, percent: 101.07}
113: {number: 114, percent: 101.19}
114: {number: 115, percent: 101.27}
115: {number: 116, percent: 100.77}
116: {number: 117, percent: 101.08}
117: {number: 118, percent: 101.41}
118: {number: 119, percent: 101.03}
119: {number: 120, percent: 100.9}
120: {number: 121, percent: 101.18}
121: {number: 122, percent: 101.33}
122: {number: 123, percent: 100.82}
123: {number: 124, percent: 101.15}
124: {number: 125, percent: 101.18}
125: {number: 126, percent: 100.83}
126: {number: 127, percent: 101.08}
127: {number: 128, percent: 101.19}
128: {number: 129, percent: 101.1}
129: {number: 130, percent: 100.76}
130: {number: 131, percent: 101.12}
131: {number: 132, percent: 101.19}
132: {number: 133, percent: 100.89}
133: {number: 134, percent: 100.88}
134: {number: 135, percent: 101.18}
135: {number: 136, percent: 101.25}
136: {number: 137, percent: 100.9}
137: {number: 138, percent: 101.22}
138: {number: 139, percent: 101.22}
139: {number: 140, percent: 100.86}
140: {number: 141, percent: 100.88}
141: {number: 142, percent: 101.15}
142: {number: 143, percent: 101.1}
143: {number: 144, percent: 100.63}
144: {number: 145, percent: 101.09}
145: {number: 146, percent: 101.23}
146: {number: 147, percent: 100.83}
147: {number: 148, percent: 101.08}
148: {number: 149, percent: 101.08}
149: {number: 150, percent: 101.08}
150: {number: 151, percent: 100.85}
151: {number: 152, percent: 101.19}
152: {number: 153, percent: 101.32}
153: {number: 154, percent: 100.8}
154: {number: 155, percent: 101.01}
155: {number: 156, percent: 101.34}
156: {number: 157, percent: 101.19}
157: {number: 158, percent: 100.86}
158: {number: 159, percent: 101.29}
159: {number: 160, percent: 101.15}
160: {number: 161, percent: 100.8}
161: {number: 162, percent: 101.23}
162: {number: 163, percent: 101.08}
163: {number: 164, percent: 100.95}
164: {number: 165, percent: 100.86}
165: {number: 166, percent: 101.06}
166: {number: 167, percent: 101.27}
167: {number: 168, percent: 100.9}
168: {number: 169, percent: 101.1}
169: {number: 170, percent: 101.35}
170: {number: 171, percent: 101.18}
171: {number: 172, percent: 100.91}
172: {number: 173, percent: 101.41}
173: {number: 174, percent: 101.29}
174: {number: 175, percent: 100.86}
175: {number: 176, percent: 101.19}
176: {number: 177, percent: 101.23}
177: {number: 178, percent: 101.14}
178: {number: 179, percent: 100.91}
179: {number: 180, percent: 101.05}
180: {number: 181, percent: 101.06}
181: {number: 182, percent: 100.92}
182: {number: 183, percent: 101.04}
183: {number: 184, percent: 100.91}
184: {number: 185, percent: 101.03}
185: {number: 186, percent: 100.99}
186: {number: 187, percent: 101.14}
187: {number: 188, percent: 101.03}
188: {number: 189, percent: 100.69}
189: {number: 190, percent: 101}
190: {number: 191, percent: 100.93}
191: {number: 192, percent: 101.03}
192: {number: 193, percent: 100.91}
193: {number: 194, percent: 101.31}
194: {number: 195, percent: 101.38}
195: {number: 196, percent: 100.94}
196: {number: 197, percent: 101.62}
197: {number: 198, percent: 101.56}
198: {number: 199, percent: 101.33}
199: {number: 200, percent: 101.44}
[200 … 236]
200: {number: 201, percent: 101.1}
201: {number: 202, percent: 101.42}
202: {number: 203, percent: 101.7}
203: {number: 204, percent: 101.42}
204: {number: 205, percent: 101.42}
205: {number: 206, percent: 101.35}
206: {number: 207, percent: 101.57}
207: {number: 208, percent: 101.42}
208: {number: 209, percent: 101.57}
209: {number: 210, percent: 101.48}
210: {number: 211, percent: 101.13}
211: {number: 212, percent: 101.6}
212: {number: 213, percent: 101.44}
213: {number: 214, percent: 101.48}
214: {number: 215, percent: 101.61}
215: {number: 216, percent: 101.16}
216: {number: 217, percent: 101.37}
217: {number: 218, percent: 101.6}
218: {number: 219, percent: 101.49}
219: {number: 220, percent: 101.42}
220: {number: 221, percent: 101.21}
221: {number: 222, percent: 101.49}
222: {number: 223, percent: 101.93}
223: {number: 224, percent: 101.87}
224: {number: 225, percent: 101.64}
225: {number: 226, percent: 101.8}
226: {number: 227, percent: 101.82}
227: {number: 228, percent: 101.5}
228: {number: 229, percent: 101.88}
229: {number: 230, percent: 102}
230: {number: 231, percent: 101.25}
231: {number: 232, percent: 101.67}
232: {number: 233, percent: 102.11}
233: {number: 234, percent: 101.57}
234: {number: 235, percent: 101.64}
235: {number: 236, percent: 101.95}
236: {number: 237, percent: 101.62}
length: 237

@jneilliii: Do you know how we could push the last ping to the Mqtt plug-in on say a 30s interval?

downloadPingHistory also works:

$.ajax({
                url: API_BASEURL + "plugin/palette2",
                type: "POST",
                dataType: "json",
                data: JSON.stringify({
                    command: "downloadPingHistory"
                }),
                contentType: "application/json; charset=UTF-8"
            }).done(function(data){console.log(data)});
{data: {…}, response: "POST request (downloadPingHistory) successful", status: 200}
data:
data: "Solar_System_Scale_New↵↵PING            (%)↵===================↵Ping 1       96.74%↵Ping 2       99.04%↵Ping 3      100.17%↵Ping 4       99.41%↵Ping 5      100.04%↵Ping 6      100.84%↵Ping 7      101.04%↵Ping 8      100.38%↵Ping 9      100.06%↵Ping 10     100.13%↵Ping 11     100.17%↵Ping 12     100.37%↵Ping 13     101.03%↵Ping 14     100.97%↵Ping 15     100.54%↵Ping 16     100.38%↵Ping 17     100.33%↵Ping 18     100.51%↵Ping 19     100.89%↵Ping 20     101.27%↵Ping 21     101.18%↵Ping 22      101.0%↵Ping 23     101.31%↵Ping 24     101.48%↵Ping 25     100.97%↵Ping 26     100.96%↵Ping 27     101.48%↵Ping 28     101.57%↵Ping 29     101.35%↵Ping 30     101.36%↵Ping 31     101.28%↵Ping 32     101.24%↵Ping 33     101.08%↵Ping 34     101.25%↵Ping 35     101.34%↵Ping 36     101.14%↵Ping 37     101.24%↵Ping 38     101.24%↵Ping 39     101.01%↵Ping 40      101.1%↵Ping 41     101.59%↵Ping 42      101.8%↵Ping 43     102.15%↵Ping 44      101.9%↵Ping 45     101.61%↵Ping 46     101.51%↵Ping 47     101.08%↵Ping 48     101.04%↵Ping 49     101.24%↵Ping 50     101.06%↵Ping 51     101.03%↵Ping 52     101.15%↵Ping 53     100.86%↵Ping 54     100.99%↵Ping 55     101.18%↵Ping 56     101.74%↵Ping 57     102.36%↵Ping 58     102.24%↵Ping 59     102.19%↵Ping 60     102.04%↵Ping 61     101.64%↵Ping 62     101.05%↵Ping 63     100.79%↵Ping 64     100.53%↵Ping 65     100.96%↵Ping 66     100.92%↵Ping 67      100.5%↵Ping 68     101.14%↵Ping 69     101.24%↵Ping 70     100.94%↵Ping 71     100.87%↵Ping 72     101.23%↵Ping 73     101.24%↵Ping 74     100.98%↵Ping 75     101.32%↵Ping 76     101.29%↵Ping 77     100.89%↵Ping 78     100.92%↵Ping 79     101.22%↵Ping 80     101.28%↵Ping 81     101.02%↵Ping 82     101.33%↵Ping 83     101.34%↵Ping 84      101.1%↵Ping 85     101.05%↵Ping 86     101.25%↵Ping 87     101.35%↵Ping 88     101.03%↵Ping 89     101.15%↵Ping 90     101.21%↵Ping 91      101.0%↵Ping 92     101.05%↵Ping 93     101.39%↵Ping 94     101.39%↵Ping 95     101.05%↵Ping 96     101.27%↵Ping 97     101.44%↵Ping 98     101.07%↵Ping 99     101.04%↵Ping 100     101.3%↵Ping 101    101.26%↵Ping 102     101.0%↵Ping 103    101.31%↵Ping 104    101.42%↵Ping 105    101.07%↵Ping 106    101.08%↵Ping 107    101.26%↵Ping 108    101.22%↵Ping 109    100.84%↵Ping 110     101.2%↵Ping 111    101.41%↵Ping 112    101.13%↵Ping 113    101.07%↵Ping 114    101.19%↵Ping 115    101.27%↵Ping 116    100.77%↵Ping 117    101.08%↵Ping 118    101.41%↵Ping 119    101.03%↵Ping 120     100.9%↵Ping 121    101.18%↵Ping 122    101.33%↵Ping 123    100.82%↵Ping 124    101.15%↵Ping 125    101.18%↵Ping 126    100.83%↵Ping 127    101.08%↵Ping 128    101.19%↵Ping 129     101.1%↵Ping 130    100.76%↵Ping 131    101.12%↵Ping 132    101.19%↵Ping 133    100.89%↵Ping 134    100.88%↵Ping 135    101.18%↵Ping 136    101.25%↵Ping 137     100.9%↵Ping 138    101.22%↵Ping 139    101.22%↵Ping 140    100.86%↵Ping 141    100.88%↵Ping 142    101.15%↵Ping 143     101.1%↵Ping 144    100.63%↵Ping 145    101.09%↵Ping 146    101.23%↵Ping 147    100.83%↵Ping 148    101.08%↵Ping 149    101.08%↵Ping 150    101.08%↵Ping 151    100.85%↵Ping 152    101.19%↵Ping 153    101.32%↵Ping 154     100.8%↵Ping 155    101.01%↵Ping 156    101.34%↵Ping 157    101.19%↵Ping 158    100.86%↵Ping 159    101.29%↵Ping 160    101.15%↵Ping 161     100.8%↵Ping 162    101.23%↵Ping 163    101.08%↵Ping 164    100.95%↵Ping 165    100.86%↵Ping 166    101.06%↵Ping 167    101.27%↵Ping 168     100.9%↵Ping 169     101.1%↵Ping 170    101.35%↵Ping 171    101.18%↵Ping 172    100.91%↵Ping 173    101.41%↵Ping 174    101.29%↵Ping 175    100.86%↵Ping 176    101.19%↵Ping 177    101.23%↵Ping 178    101.14%↵Ping 179    100.91%↵Ping 180    101.05%↵Ping 181    101.06%↵Ping 182    100.92%↵Ping 183    101.04%↵Ping 184    100.91%↵Ping 185    101.03%↵Ping 186    100.99%↵Ping 187    101.14%↵Ping 188    101.03%↵Ping 189    100.69%↵Ping 190     101.0%↵Ping 191    100.93%↵Ping 192    101.03%↵Ping 193    100.91%↵Ping 194    101.31%↵Ping 195    101.38%↵Ping 196    100.94%↵Ping 197    101.62%↵Ping 198    101.56%↵Ping 199    101.33%↵Ping 200    101.44%↵Ping 201     101.1%↵Ping 202    101.42%↵Ping 203     101.7%↵Ping 204    101.42%↵Ping 205    101.42%↵Ping 206    101.35%↵Ping 207    101.57%↵Ping 208    101.42%↵Ping 209    101.57%↵Ping 210    101.48%↵Ping 211    101.13%↵Ping 212     101.6%↵Ping 213    101.44%↵Ping 214    101.48%↵Ping 215    101.61%↵Ping 216    101.16%↵Ping 217    101.37%↵Ping 218     101.6%↵Ping 219    101.49%↵Ping 220    101.42%↵Ping 221    101.21%↵Ping 222    101.49%↵Ping 223    101.93%↵Ping 224    101.87%↵Ping 225    101.64%↵Ping 226     101.8%↵Ping 227    101.82%↵Ping 228     101.5%↵Ping 229    101.88%↵Ping 230     102.0%↵Ping 231    101.25%↵Ping 232    101.67%↵Ping 233    102.11%↵Ping 234    101.57%↵Ping 235    101.64%↵Ping 236    101.95%↵Ping 237    101.62%↵Ping 238    101.63%↵Ping 239    101.93%↵Ping 240    101.46%↵Ping 241    101.18%↵"
filename: "Solar_System_Scale_New.txt"
__proto__: Object
response: "POST request (downloadPingHistory) successful"
status: 200

Look at the code of my mqtt-publish plugin. It has all the necessary info for using the mqtt plugin's helpers and sending the data. You'd just have to wrap your api call/post-processing (get last ping)/mqtt publish in a repeated timer.

1 Like

Cheers. Will look into it. Giving myself a headache prodding around trying to get other commands working unsuccessfully...

OK, this solution is node ideal for me. I'm going to try to push for more API calls. Opened a Feature Request on GitLab here: https://gitlab.com/mosaic-mfg/palette-2-plugin/issues/8
My coding abilisties do not allow for me to make the commits without assistance!

The wonderful @gdombi made himself available and sorted this out here: https://gitlab.com/mosaic-mfg/palette-2-plugin/-/merge_requests/94

1 Like

@Monkey_House
Happy New Year 2021

I hope you wouldn't mind me asking how far did you get with that Palette sensor for Home Assistant?
I checked the above conversation and replicated your sensor snippets with no result.