Initial commit
This commit is contained in:
24
sports/scores.js
Normal file
24
sports/scores.js
Normal 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"})
|
||||
}
|
Reference in New Issue
Block a user