Forgot a node from the sports flow
This commit is contained in:
41
sports/init.js
Normal file
41
sports/init.js
Normal file
@ -0,0 +1,41 @@
|
||||
const states = global.get('homeassistant.homeAssistant.states')
|
||||
const team = flow.get("activeEvent", "diskCon")
|
||||
const room = flow.get("activeRoom", "diskCon")
|
||||
|
||||
if (team === 'No events today') {
|
||||
node.status({ fill: "red", shape: "ring", text: "No events today" })
|
||||
node.done
|
||||
} else {
|
||||
const lowerTeam = team.toLowerCase()
|
||||
const convertTeam = lowerTeam.replaceAll(" ", "_")
|
||||
const sensor = "sensor." + convertTeam
|
||||
const getInhibitSensor = "binary_sensor." + convertTeam + "_inhibit"
|
||||
const inhibit = states[getInhibitSensor].state
|
||||
const teamSensor = states[sensor]
|
||||
const lowerRoom = room.toLowerCase()
|
||||
const convertRoom = lowerRoom.replaceAll(" ","_")
|
||||
const teamColors = teamSensor.attributes.team_colors
|
||||
const oppColors = teamSensor.attributes.opponent_colors
|
||||
|
||||
flow.set("team", convertTeam, "diskCon")
|
||||
flow.set("inhibit", inhibit, "diskCon")
|
||||
flow.set("teamSensor", teamSensor, "diskCon")
|
||||
flow.set("room", convertRoom, "diskCon")
|
||||
flow.set("teamColors", teamColors, "diskCon")
|
||||
flow.set("oppColors", oppColors, "diskCon")
|
||||
|
||||
let sendTeam = {
|
||||
"payload": teamColors,
|
||||
"topic": "teamColors"
|
||||
}
|
||||
|
||||
let sendOpp = {
|
||||
"payload": oppColors,
|
||||
"topic": "oppColors"
|
||||
}
|
||||
|
||||
node.send([[sendTeam,sendOpp]])
|
||||
|
||||
node.status({fill:"green",shape:"dot",text:"Team: " + team})
|
||||
node.log("Active sports team changed to " + team)
|
||||
}
|
Reference in New Issue
Block a user