18 lines
795 B
JavaScript
18 lines
795 B
JavaScript
const HomeAssistant = require('homeassistant');
|
|
const hass = new HomeAssistant({
|
|
host: 'http://192.168.4.5',
|
|
port: 8123,
|
|
// token: process.env.homeAssistantKey,
|
|
token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxNjgyODUxMWI4Nzc0YTAwYTA0ZGRmYzgyZWIzODRlZiIsImlhdCI6MTYwMDEwNjMxOSwiZXhwIjoxOTE1NDY2MzE5fQ.18uSUFbLMJnlQBuhUO6uXL25fZ7jBzyU3i5qiOCgnuc",
|
|
ignoreCert: false
|
|
});
|
|
async function main() {
|
|
let jobPercentage = await hass.states.get('sensor', 'octoprint_job_percentage')
|
|
let timeRemaining = await hass.states.get('sensor', 'octoprint_time_remaining')
|
|
let percent = jobPercentage.state + jobPercentage.attributes.unit_of_measurement
|
|
console.log(percent)
|
|
console.log(new Date(timeRemaining.state * 1000).toISOString().substr(11, 8) )
|
|
|
|
}
|
|
|
|
main() |