Initial commit

This commit is contained in:
2023-09-28 12:28:27 -04:00
commit 25780c8c5d
30 changed files with 1777 additions and 0 deletions

24
sports/scores.js Normal file
View File

@ -0,0 +1,24 @@
// Get sensor
const states = global.get('homeassistant.homeAssistant.states')
const active = states['switch.watching_sports'].state
if (active === 'on') {
// Get scores
const team = flow.get("team")
const teamSensor = states["sensor." + team]
const status = teamSensor.state
if (status === 'IN') {
const teamScore = teamSensor.attributes.team_score
const oppScore = teamSensor.attributes.opponent_score
msg = {
"teamscore": teamScore,
"oppscore": oppScore
}
node.status({fill:"green",shape:"dot",text:"Score: " + teamScore + "-" + oppScore})
node.send(msg)
} else {
node.status({fill:"red",shape:"ring",text:"Not in game"})
}
} else {
node.status({fill:"red",shape:"ring",text:"Inactive"})
}