Hi,
I am now able to at least read data from my Vallox automatic ventilation ValloPlus 350MV. I am using phantomjs (fortunately included in the docker-image of home assistant) to access the web-interface of the ventilation as this makes heavy use of Javascript (Jquery). Sorry these are my first steps in Javascript so expect it to be ugly and buggy.
So far at least reading the values works. Controlling the switches is my next focus. Challenge seems to be that not all switches are visible per default. However this approach might also be a start for accessing other webinterfaces with Javascript/Jquery, where no other interface exists. Potentially the ValloPlus should be also accessible by Modbus. However as I already had it connected to my Network (and have no experience with modbus either) I wanted to try this first.
I have stored the javascript-file for phantomjs in config/vallox/read_vallox.js:
var system = require('system');
var webPage = require('webpage');
var page = webPage.create();
var url = system.args[1];
var requestsArray = [];
page.onResourceRequested = function(requestData, networkRequest) {
requestsArray.push(requestData.id);
};
// to circumvent issue that console.log is normally not available.
page.onAlert = function(msg) {
console.log(msg);
page.onResourceReceived = function(response) {
var index = requestsArray.indexOf(response.id);
requestsArray.splice(index, 1);
};
page.open(url, function(status) {
var interval = setInterval(function () {
if (requestsArray.length === 0) {
clearInterval(interval);
var pageData = page.evaluate(function() {
window.console.log = function(msg) { alert(msg) };
// Model
console.log(document.querySelector('div.dashboard-panel div.wizard-panel-device.wizard-panel-device-active p').innerHTML.trim());
// Temp Supply Air
console.log(document.querySelector('div[l10n-path="dashboard.now.supply"] p').innerHTML.trim().replace(' °C',''));
// Humidity
console.log( document.querySelector('div[l10n-path="info.diagnostics.rh.sensors.0"] p').innerHTML.trim().replace('%',''));
// Temp indor Air
console.log(document.querySelector('div[l10n-path="dashboard.now.indoor"] p').innerHTML.trim().replace(' °C',''));
// Power Status (attention: Language)
console.log(document.querySelector('div[l10n-path="info.status.power"] p').innerHTML.trim());
// Temp outdoor
console.log(document.querySelector('div[l10n-path="dashboard.now.outdoor"] p').innerHTML.trim().replace(' °C',''));
// Temp Exhaust
console.log(document.querySelector('div[l10n-path="dashboard.now.exhaust"] p').innerHTML.trim().replace(' °C',''));
console.log(document.querySelector('div[l10n-path="dashboard.profile.fanspeed"] p').innerHTML.trim().replace('%',''));
//return document.querySelector('div[l10n-path="dashboard.now.supply"] p');
});
phantom.exit();
}
}, 5000);
});
Now in the configuration I have defined one command line sensor which reads all values at once and is split via template sensors:
sensor:
- platform: command_line
# Vallox Sensor
# /usr/bin/phantomjs /config/vallox/read_vallox.js
name: Vallox Gesamt
command: "/usr/bin/phantomjs /config/vallox/read_vallox.js http://192.168.70.20"
scan_interval: 120
- platform: template
sensors:
vallox_model:
friendly_name: 'Vallox Model'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[0] }}"
vallox_temp_supply:
friendly_name: 'Vallox Temp Zuluft'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[1] | int }}"
unit_of_measurement: '°C'
vallox_humidity:
friendly_name: 'Vallox Rel. LF'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[2] | int }}"
unit_of_measurement: '%'
vallox_temp_indoor:
friendly_name: 'Vallox Temp Innen'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[3] | int }}"
unit_of_measurement: '°C'
vallox_power:
friendly_name: 'Vallox Ein/Aus'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[4] }}"
vallox_temp_outdoor:
friendly_name: 'Vallox Temp AuĂen'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[5] | int }}"
unit_of_measurement: '°C'
vallox_temp_exhaust:
friendly_name: 'Vallox Abluft'
value_template: "{% set list = states.sensor.vallox_gesamt.state.split('\n') %} {{ list[6] | int }}"
unit_of_measurement: '°C'
So far reading the sensors works fine although there is probably some improvement potential (e.g. the interval âworkaroundâ - as the page in JS takes very long to load - might check actually for some date, have the Javascript return JSON to avoid further formatting), etc.
controlling / clicking so far was not successful. I started with:
document.querySelector(âa[l10n-path=âdashboard.profile.list.0.activateâ]â).click();
within the page.evaluate. However this seems to have no effect but I will continue experimenting and keep posting here. Hope that this might help others.