Precommit

This commit is contained in:
Shaun Eccles-Smith 2021-08-19 10:12:48 +10:00
parent 8c13b4d143
commit 340d3f368a
29 changed files with 196 additions and 179 deletions

View File

@ -25,7 +25,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
rev: v2.13.0
rev: v2.23.3
hooks:
- id: pyupgrade
args: [--py310-plus]
args: [--py38-plus]

View File

@ -119,7 +119,7 @@ Other News
Version 0.11.0
=============
- If device is WLED & active effect, than display WLED info
Version 0.9.2

View File

@ -40,7 +40,7 @@ const IntegrationsCard = ({ int }) => {
};
const handleToggle = (props) => toggleAsyncIntegration(props);
//const preventDefault = (event) => event.preventDefault();
useEffect(() => {
// EVERTHING HERE IS ONLY CALLED ONCE WHEN THIS COMPONENT IS RENDERED, Only call if {int.type === 'qlc'}
if(int.status === 1 & int.type === 'qlc') dispatch(getAsyncqlclisteners(int.id))
@ -74,7 +74,7 @@ const IntegrationsCard = ({ int }) => {
: 'Unknown'}
</Typography>
<Typography color="textSecondary" gutterBottom>
<Link target="_blank" href="http://127.0.0.1:9999" >
<Link target="_blank" href="http://127.0.0.1:9999" >
{int.type === 'qlc'
? `QLC+ API: http://${int.config.ip_address}:${int.config.port}`
: ''}
@ -88,14 +88,14 @@ const IntegrationsCard = ({ int }) => {
{int.status === 1 & int.type === 'qlc'
? <DialogAddEventListener integration={int} />
: int.status !== 1 & int.type === 'qlc'
?
?
<Link target="_blank" href="https://www.qlcplus.org/docs/html_en_EN/webinterface.html" >
Must be in connected status, to add new event listener. Click here for setup guide.
</Link>
: ''}
{int.type === 'spotify' && int.active
?
{int.type === 'spotify' && int.active
?
<SpotifyView />
: ''}
</CardActions>
@ -125,12 +125,12 @@ const IntegrationsCard = ({ int }) => {
//onClick={handleClickListItem}
//Need to do, onClick: Re-render switch and integrations Redux.
/>
</CardActions>
</Card>
);
};
export default IntegrationsCard;

View File

@ -21,11 +21,11 @@ import ThisDropDown from './DialogAddEventListnerDropDown';
import {createQlcListener} from 'modules/qlc';
//import * as integrationsProxies from 'proxies/integrations';
//To Do:
//To Do:
//useEffect(() => {
//getScenes();
//}, []);
function ConfirmationDialogRaw(props) {
const { onClose, value: valueProp, open, ...other } = props;
const [value, setValue] = React.useState(valueProp);
@ -57,12 +57,12 @@ function ConfirmationDialogRaw(props) {
const qlcStuff = []
const qlcID = {}
//const qlcType = {}
qlcInfo && qlcInfo.qlc_widgets && qlcInfo.qlc_widgets.map((a) => {
qlcInfo && qlcInfo.qlc_widgets && qlcInfo.qlc_widgets.map((a) => {
qlcStuff[a[0]] = {id: a[0], Type: a[1], Name: a[2]}
qlcID[a[0]] = (a[1]);
//qlcType[a[0]] = (a[1]);
});
React.useEffect(() => {
if (!open) {
setValue(valueProp);
@ -86,10 +86,10 @@ function ConfirmationDialogRaw(props) {
console.log("QLCFormEventTest1",data);
dispatch(createQlcListener(props.integration.id,formData));
// props.createQlcListener(props.integration.id,formData);
// window.location = window.location.href;
};
const onModelChange = (key, val) => {
utils.selectOrSet(key, model, val);
};
@ -112,7 +112,7 @@ function ConfirmationDialogRaw(props) {
setSwitchValue(event.target.checked);
setqlcData(qlcDatanewArr);
console.log("test",newSwitchState)
setformData(newSwitchState);
setformData(newSwitchState);
}else if(event.target.name === 'qlc_payload'){
const qlcDatanewArr = qlcData.slice();
let qlcDataObj = {
@ -122,8 +122,8 @@ function ConfirmationDialogRaw(props) {
setSwitchValue(false);
setqlcData(qlcDatanewArr);
let newqlcPayload = Object.assign({},...qlcDatanewArr);
let newSwitchState = {
...formData,
"qlc_payload":{
@ -132,7 +132,7 @@ function ConfirmationDialogRaw(props) {
};
console.log("test",newSwitchState)
setformData(newSwitchState)
}else if(event.target.name === 'scene_name'){
value = JSON.parse(value);
let newFormState = {
@ -143,7 +143,7 @@ function ConfirmationDialogRaw(props) {
},
"event_type":value["event_type"]
};
setformData(newFormState);
setformData(newFormState);
}else{
// console.log("typetest",val);
// console.log("typevalue",checkID);
@ -157,14 +157,14 @@ function ConfirmationDialogRaw(props) {
},
};
setSliderValue(val);
setformData(newSliderState);
setformData(newSliderState);
}
// setformData(inputs => ({...inputs, [event.target.name]: event.target.value}));
};
const handleTypeChange = (event) => {
event.target.value.includes("Button")?setButtonType(true):setButtonType(false);
event.target.value.includes("Slider")?setSliderType(true):setSliderType(false);
@ -186,7 +186,7 @@ function ConfirmationDialogRaw(props) {
newArr[index].showSwitch = false;
}
// if(event.target.name === "qlc_payload"){
// }
let value = event.target.value;
if(event.target.type === "checkbox"){
@ -201,9 +201,9 @@ function ConfirmationDialogRaw(props) {
...newqlcPayload
},
};
setqlcData(qlcDatanewArr);
setformData(newSwitchState);
setformData(newSwitchState);
}else if(event.target.name === 'qlc_payload'){
newArr[index]["value"] = event.target.value[0];
console.log("test13",newArr);
@ -218,11 +218,11 @@ function ConfirmationDialogRaw(props) {
newArr[index].switchValue = false;
qlcDatanewArr[index+1] = qlcDataObj;
}
setqlcData(qlcDatanewArr);
let newqlcPayload = Object.assign({},...qlcDatanewArr)
let newSwitchState = {
...formData,
"qlc_payload":{
@ -230,7 +230,7 @@ function ConfirmationDialogRaw(props) {
},
};
console.log("test",newSwitchState)
setformData(newSwitchState)
setformData(newSwitchState)
}else{
const qlcDatanewArr = qlcData.slice();
qlcDatanewArr[index+1][name] = val;
@ -241,13 +241,13 @@ function ConfirmationDialogRaw(props) {
...newqlcPayload
},
};
setqlcData(qlcDatanewArr);
setformData(newSliderState);
}
return setdropDownRenderList(newArr);
};
const handleTypeAddDropDown = (event) => {
@ -279,7 +279,7 @@ function ConfirmationDialogRaw(props) {
};
console.log("test",newSwitchState)
setformData(newSwitchState)
return setdropDownRenderList(newArr);
return setdropDownRenderList(newArr);
}
const marks = [
@ -288,7 +288,7 @@ function ConfirmationDialogRaw(props) {
];
delete other.deviceList;
return (
<Dialog
disableBackdropClick
@ -305,12 +305,12 @@ function ConfirmationDialogRaw(props) {
<DialogContent dividers>
<DialogContentText>
To add a Event Listener to LedFx, please first select the type of event trigger (If This),
and then provide the expected output (Then Do This).
and then provide the expected output (Then Do This).
</DialogContentText>
<FormControl>
<InputLabel htmlFor="grouped-select">Event Trigger (If This)</InputLabel>
<Select
id="grouped-select"
<Select
id="grouped-select"
defaultValue ={formData["event_filter"]["scene_name"]}
name="scene_name"
onChange={handleEventChange}
@ -322,8 +322,8 @@ function ConfirmationDialogRaw(props) {
Scene Set
</ListSubheader>
{SceneSet && SceneSet.length > 0 && SceneSet.map((val,idx)=>
<MenuItem
key={idx}
<MenuItem
key={idx}
value={JSON.stringify({"event_type":"scene_set","event_name":val})}
name={val}
>
@ -337,8 +337,8 @@ function ConfirmationDialogRaw(props) {
Effect Set
</ListSubheader>
{effectNames && effectNames.length > 1 && effectNames.map((val,idx)=>
<MenuItem
key={idx}
<MenuItem
key={idx}
value={JSON.stringify({"event_type":"effect_set","event_name":val})}
name={val}
>
@ -347,7 +347,7 @@ function ConfirmationDialogRaw(props) {
</option>
</MenuItem>)
}
<ListSubheader color="primary">
Effect Cleared
</ListSubheader>
@ -366,8 +366,8 @@ function ConfirmationDialogRaw(props) {
>
<MenuItem value=""></MenuItem>
{QLCWidgets && QLCWidgets.length > 0 && QLCWidgets.map((e,f)=>
<MenuItem
key={f}
<MenuItem
key={f}
value={e}
name={e[0]}>
<option>
@ -379,7 +379,7 @@ function ConfirmationDialogRaw(props) {
</MenuItem>)
}
</Select>
{/*
If {qlcType} === 'Button' or 'Audio Triggers'
return switch off (Value: 0) or on (Value: 255)
@ -389,23 +389,23 @@ function ConfirmationDialogRaw(props) {
Else hide below buttons.
*/}
</FormControl>
{/* For delete button using delete icon.
<Button aria-describedby={id} variant="contained" color="primary" onClick={() => { onDeleteVitem(listItem) }}>
<DeleteIcon />
</Button>
*/}
{/* <div style={{ minWidth: '150px' }}></div> */}
<div>
{checkButtonType && <label>QLC+ widget selected above (On/Off) </label>}
{checkButtonType &&
<Switch
{checkButtonType &&
<Switch
color="primary"
// value={!formData.switch_value?255:0}
checked={switchValue}
name={checkID}
onChange={handleEventChange}
onChange={handleEventChange}
/>
}</div>
@ -421,10 +421,10 @@ function ConfirmationDialogRaw(props) {
max={255}
defaultValue={1}
value={sliderValue}
onChange={handleEventChange}
onChange={handleEventChange}
/>
}
</div>
</div>
{dropDownRenderList.map((item,idx) => (
<ThisDropDown
key={idx}
@ -455,7 +455,7 @@ function ConfirmationDialogRaw(props) {
>
ADD additional 'then do this'
</Button>
<SchemaForm
// className={classes.schemaForm}
schema={{
@ -510,7 +510,7 @@ export default function ConfirmationDialog({ deviceList, config, integration })
const [open, setOpen] = React.useState(false);
const dispatch = useDispatch();
//console.log("YZ03:", event_types)
const handleClickListItem = ()=> {
setOpen(true);
};
@ -532,7 +532,7 @@ export default function ConfirmationDialog({ deviceList, config, integration })
onClick={handleClickListItem}
role="listitem"
>
ADD EVENT LISTENER
ADD EVENT LISTENER
</Button>
<ConfirmationDialogRaw

View File

@ -35,8 +35,8 @@ export default function ThisDropDown(props) {
<button variant="contained" color="primary" onClick={()=>props.handleTypeRemoveDropDown(props.idx)}><DeleteIcon/></button>
<div style={{ minWidth: '150px' }}></div>
{props.showSwitch && <label>QLC+ widget selected above (On/Off) </label>}
{props.showSwitch &&
<Switch
{props.showSwitch &&
<Switch
color="primary"
name={props.value}
checked={props.switchValue}
@ -55,7 +55,7 @@ export default function ThisDropDown(props) {
defaultValue={1}
onChange={(event,value)=>props.handleDropTypeChange(event,props.idx,value,props.value)}
/>}
</div>
</div>
</>
);
}

View File

@ -50,7 +50,7 @@ function ConfirmationDialogRaw(props) {
// setModel(val);
};
delete other.deviceList;
return integrationTypes[integration] ? (
<Dialog
disableBackdropClick

View File

@ -24,7 +24,7 @@ class SpotifyView extends React.Component {
const codes = pkceChallenge();
const cookies = new Cookies();
cookies.set('verifier', codes.code_verifier)
let authURL =
let authURL =
`https://accounts.spotify.com/authorize/`
+ "?response_type=code"
+ "&client_id="+encodeURIComponent('7658827aea6f47f98c8de593f1491da5')
@ -34,7 +34,7 @@ class SpotifyView extends React.Component {
+ "&code_challenge_method=S256"
;
console.log(authURL)
window.location.href = authURL
window.location.href = authURL
}
componentDidMount() {
@ -43,17 +43,17 @@ class SpotifyView extends React.Component {
}
this.props.checkCookiesForTokens()
}
render() {
const { spotify, refreshAuth } = this.props;
return (
<Grid container justify='center' alignContent='center' style={{height: '10%'}}>
{!spotify.accessToken && !spotify.refreshToken ?
{!spotify.accessToken && !spotify.refreshToken ?
''
:
!spotify.accessToken && spotify.refreshToken ?
:
!spotify.accessToken && spotify.refreshToken ?
''
:
:
<div style={{width: '100%'}}>
<SpotifyPlayer />
<TriggersList />

View File

@ -11,12 +11,12 @@ import { useEffect } from 'react';
const SpotifyView = (props)=> {
//const { spotify, refreshAuth } = this.props;
const spotify = useSelector(state => state.spotify);
const beginAuth = () => {
const codes = pkceChallenge();
const cookies = new Cookies();
cookies.set('verifier', codes.code_verifier)
let authURL =
let authURL =
`https://accounts.spotify.com/authorize/`
+ "?response_type=code"
+ "&client_id="+encodeURIComponent('7658827aea6f47f98c8de593f1491da5')
@ -26,7 +26,7 @@ const SpotifyView = (props)=> {
+ "&code_challenge_method=S256"
;
console.log(authURL)
window.location.href = authURL
window.location.href = authURL
}
useEffect(() => {
@ -35,26 +35,26 @@ const SpotifyView = (props)=> {
console.log('Got to here')
finishAuth()
}
checkCookiesForTokens()
}, [])
checkCookiesForTokens()
}, [])
return (
<Grid container justify='center' alignContent='center' style={{height: '10%'}}>
{!spotify.accessToken && !spotify.refreshToken ?
{!spotify.accessToken && !spotify.refreshToken ?
<Button variant='contained' color="primary" onClick={() => beginAuth()}>
<Typography>Connect to Spotify</Typography>
</Button>
:
!spotify.accessToken && spotify.refreshToken ?
</Button>
:
!spotify.accessToken && spotify.refreshToken ?
<Button variant='contained' color="primary" onClick={() => refreshAuth()}>
<Typography>Reconnect to Spotify</Typography>
</Button>
:
:
''
}
</Grid>
);
}
export default SpotifyView;

View File

@ -62,7 +62,7 @@ const useStyles = makeStyles(theme => ({
class SpotifyPlayer extends React.Component {
constructor(props) {
super(props);
this.state = {
this.state = {
sliderPositon: 0,
includePosition: 'false',
effects: ''
@ -79,9 +79,9 @@ class SpotifyPlayer extends React.Component {
player.addListener('authentication_error', ({ message }) => { console.error(message); });
player.addListener('account_error', ({ message }) => { console.error(message); });
player.addListener('playback_error', ({ message }) => { console.error(message); });
player.addListener('player_state_changed', state => {
player.addListener('player_state_changed', state => {
if (state.position < 5 || state.position > 500) {
this.props.updatePlayerState(state);
this.props.updatePlayerState(state);
}
});
player.addListener('ready', ({ device_id }) => {
@ -126,7 +126,7 @@ class SpotifyPlayer extends React.Component {
render() {
const { playerState, classes,scenes } = this.props;
return (
Object.keys(playerState).length == 0 ?
<Link target="_blank" href="https://support.spotify.com/us/article/spotify-connect/" >
@ -137,14 +137,14 @@ class SpotifyPlayer extends React.Component {
<AppBar color="default" position='relative' className={classes.appBar}>
<Grid container justify='space-around' alignItems='center' className={classes.container}>
<Grid container item xs={4}>
<img style={{alignItems: 'center'}} className={classes.albumImg} src={playerState.track_window.current_track.album.images[0].url} alt=""/>
<img style={{alignItems: 'center'}} className={classes.albumImg} src={playerState.track_window.current_track.album.images[0].url} alt=""/>
<div style={{width: '200px', marginLeft: '2vw', display: 'flex', alignItems: 'center'}}>
<Typography align='center' variant='body1'>
Song: {playerState.track_window.current_track.name}
Song: {playerState.track_window.current_track.name}
<div>Artist: {playerState.track_window.current_track.artists[0].name}</div>
</Typography>
</div>
</Grid>
<Grid item container xs={7}>
<Grid item xs={6}>
@ -155,8 +155,8 @@ class SpotifyPlayer extends React.Component {
color="primary"
onChange={(e) => this.handleSelectChange(e)}
labelId='select'>
{scenes.length && scenes.map((s,i) => <option value={s.id} key={i}>{s.name}</option>)}
{scenes.length && scenes.map((s,i) => <option value={s.id} key={i}>{s.name}</option>)}
</Select>
</FormControl>
</Grid>
@ -169,14 +169,14 @@ class SpotifyPlayer extends React.Component {
?
<Button style={{marginRight: '1.8rem'}} color="primary" variant="contained"><PlayArrow /></Button>
:
<Button style={{marginRight: '1.8rem'}} color="primary" variant="contained"><Pause /></Button> }
<Button style={{marginRight: '1.8rem'}} color="primary" variant="contained"><SkipNext /></Button>
<Button style={{marginRight: '1.8rem'}} color="primary" variant="contained"><Pause /></Button> }
<Button style={{marginRight: '1.8rem'}} color="primary" variant="contained"><SkipNext /></Button>
</div>
</Grid>
<Grid container item xs={6} justify='center'>
<Typography align='center' variant='body1'><div>
Track Position: .
{playerState.paused === false
@ -201,7 +201,7 @@ class SpotifyPlayer extends React.Component {
</div>
</Typography>
<Typography align='center' variant='body1'><div>
Testing:
Testing:
{playerState.paused === false
?
<Moment
@ -212,7 +212,7 @@ class SpotifyPlayer extends React.Component {
{moment().add(playerState.position * -1,'ms')}
</Moment>
//moment().add(playerState.position* -0.001, 's')/playerState.duration*100
:
:
(playerState.position/playerState.duration*100)
} </div>
</Typography>
@ -233,8 +233,8 @@ class SpotifyPlayer extends React.Component {
export default connect(
state => ({
playerState: state.spotify.playerState,
accessToken: state.spotify.accessToken,
scenes: state.scenes.list,
accessToken: state.spotify.accessToken,
scenes: state.scenes.list,
}),
{ updatePlayerState }
)(withStyles(styles)(SpotifyPlayer));

View File

@ -20,13 +20,13 @@ class TriggerList extends React.Component {
super(props);
this.state = { }
};
render() {
const { } = this.props;
return (
<Card>
<CardContent>
{triggers.length > 0 ?
{triggers.length > 0 ?
<List>
<ListItem>
<ListItemText primary='Song' secondary='Position' />

View File

@ -52,13 +52,13 @@ export function getAsyncIntegrations() {
};
}
export async function deleteAsyncIntegration(data) {
const response = await integrationsProxies.deleteIntegration({ data });
export async function deleteAsyncIntegration(data) {
const response = await integrationsProxies.deleteIntegration({ data });
window.location = window.location.href;
// integrationsProxies.deleteIntegration(data);
return async dispatch => {
try {
//const response =
try {
//const response =
await integrationsProxies.deleteIntegration(data);
if (response.statusText === 'OK') {
console.log('OMG', response.data);
@ -73,21 +73,21 @@ export async function deleteAsyncIntegration(data) {
export async function toggleAsyncIntegration(data) {
console.log('toggleAsyncIntegration: ', data);
// 1) You would want to do a try catch around this. but its ok for dev
//const response =
await integrationsProxies.toggleIntegration({id: data});
//const response =
await integrationsProxies.toggleIntegration({id: data});
// 2) you dont want to do the reload here
// 2) you dont want to do the reload here
// delete this after you have dispatched the new data to the store
window.location = window.location.href;
return async dispatch => {
try {
console.log('damn', data);
const response = await integrationsProxies.toggleIntegration({id: data});
if (response.statusText === 'OK') {
console.log('OMG', response.data);
// Here is were you normally want to dispatch the action
// you defined at the top of this file line 16-36:
// Here is were you normally want to dispatch the action
// you defined at the top of this file line 16-36:
// like storing new state to store
// dispatch(deleteIntegration(response.data.integrations));
}

View File

@ -41,7 +41,7 @@ const IntegrationsView = () => {
useEffect(() => {
dispatch(getScenes());
}, [dispatch]);
return (
<><Grid container spacing={2}>
<Grid item xs={12} md={12}>

View File

@ -24,7 +24,7 @@ class SpotifyView extends React.Component {
const codes = pkceChallenge();
const cookies = new Cookies();
cookies.set('verifier', codes.code_verifier)
let authURL =
let authURL =
`https://accounts.spotify.com/authorize/`
+ "?response_type=code"
+ "&client_id="+encodeURIComponent('98c377701d74421abe1b466ecfada5fa')
@ -34,7 +34,7 @@ class SpotifyView extends React.Component {
+ "&code_challenge_method=S256"
;
console.log(authURL)
window.location.href = authURL
window.location.href = authURL
}
componentDidMount() {
@ -43,21 +43,21 @@ class SpotifyView extends React.Component {
}
this.props.checkCookiesForTokens()
}
render() {
const { spotify, refreshAuth } = this.props;
return (
<Grid container justify='center' alignContent='center' style={{height: '90%'}}>
{!spotify.accessToken && !spotify.refreshToken ?
{!spotify.accessToken && !spotify.refreshToken ?
<Button variant='contained' color="primary" onClick={() => this.beginAuth()}>
<Typography>Connect to Spotify</Typography>
</Button>
:
!spotify.accessToken && spotify.refreshToken ?
</Button>
:
!spotify.accessToken && spotify.refreshToken ?
<Button variant='contained' color="primary" onClick={() => refreshAuth()}>
<Typography>Connect to Spotify</Typography>
</Button>
:
:
<div style={{width: '100%'}}>
<SpotifyPlayer />
<TriggersList />

View File

@ -173,9 +173,9 @@ class ConfigEndpoint(RestEndpoint):
# handle special case wled_preferences nested dict
for key in wled_config:
if key in self._ledfx.config["wled_preferences"]:
self._ledfx.config["wled_preferences"][key].update(wled_config[
key
])
self._ledfx.config["wled_preferences"][key].update(
wled_config[key]
)
else:
self._ledfx.config["wled_preferences"][key] = wled_config[
key

View File

@ -14,7 +14,7 @@ class FindDevicesEndpoint(RestEndpoint):
ENDPOINT_PATH = "/api/find_devices"
async def post(self) -> web.Response:
""" Find and add all WLED devices on the LAN """
"""Find and add all WLED devices on the LAN"""
def handle_exception(future):
# Ignore exceptions, these will be raised when a device is found that already exists

View File

@ -55,7 +55,7 @@ class QLCEndpoint(RestEndpoint):
return web.json_response(data=response, status=200)
async def put(self, integration_id, request) -> web.Response:
""" Toggle a QLC event listener """
"""Toggle a QLC event listener"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "qlc"):
response = {"not found": 404}
@ -115,7 +115,7 @@ class QLCEndpoint(RestEndpoint):
return web.json_response(data=response, status=200)
async def post(self, integration_id, request) -> web.Response:
""" Add a new QLC event listener or update an existing one """
"""Add a new QLC event listener or update an existing one"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "qlc"):
response = {"not found": 404}
@ -178,7 +178,7 @@ class QLCEndpoint(RestEndpoint):
return web.json_response(data=response, status=200)
async def delete(self, integration_id, request) -> web.Response:
""" Delete a QLC event listener """
"""Delete a QLC event listener"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "qlc"):
response = {"not found": 404}

View File

@ -16,7 +16,7 @@ class QLCEndpoint(RestEndpoint):
ENDPOINT_PATH = "/api/integrations/spotify/{integration_id}"
async def get(self, integration_id) -> web.Response:
""" Get all song triggers """
"""Get all song triggers"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "spotify"):
response = {"not found": 404}
@ -27,7 +27,7 @@ class QLCEndpoint(RestEndpoint):
return web.json_response(data=response, status=200)
async def put(self, integration_id, request) -> web.Response:
""" Update a Spotify song trigger """
"""Update a Spotify song trigger"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "spotify"):
response = {"not found": 404}
@ -40,7 +40,7 @@ class QLCEndpoint(RestEndpoint):
return web.json_response(data=response, status=200)
async def post(self, integration_id, request) -> web.Response:
""" Add Spotify song trigger """
"""Add Spotify song trigger"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "spotify"):
response = {"not found": 404}
@ -90,7 +90,7 @@ class QLCEndpoint(RestEndpoint):
return web.json_response(data=response, status=200)
async def delete(self, integration_id, request) -> web.Response:
""" Delete a Spotify song trigger """
"""Delete a Spotify song trigger"""
integration = self._ledfx.integrations.get(integration_id)
if (integration is None) or (integration.type != "spotify"):
response = {"not found": 404}

View File

@ -123,7 +123,7 @@ class IntegrationsEndpoint(RestEndpoint):
response = {"not found": 404}
return web.Response(text=json.dumps(response), status=404)
if hasattr(integration, 'on_delete'):
if hasattr(integration, "on_delete"):
await integration.on_delete()
self._ledfx.integrations.destroy(integration_id)

View File

@ -110,9 +110,12 @@ class SchemaEndpoint(RestEndpoint):
elif schema == "audio":
# Get audio schema
response["audio"] = {
"schema": {**convertToJsonSchema(
AudioInputSource.AUDIO_CONFIG_SCHEMA.fget(),
), **{ "permitted_keys": PERMITTED_KEYS["audio"] }}
"schema": {
**convertToJsonSchema(
AudioInputSource.AUDIO_CONFIG_SCHEMA.fget(),
),
**{"permitted_keys": PERMITTED_KEYS["audio"]},
}
# | { "properties": {
# "audio_device": {
# "enum": {
@ -126,25 +129,36 @@ class SchemaEndpoint(RestEndpoint):
elif schema == "melbanks":
# Get melbanks schema
response["melbanks"] = {
"schema": {**convertToJsonSchema(
Melbanks.CONFIG_SCHEMA,
), **{ "permitted_keys": PERMITTED_KEYS["melbanks"] }},
"schema": {
**convertToJsonSchema(
Melbanks.CONFIG_SCHEMA,
),
**{"permitted_keys": PERMITTED_KEYS["melbanks"]},
},
}
elif schema == "wled_preferences":
# Get wled schema
response["wled_preferences"] = {
"schema": {**convertToJsonSchema(
WLED_CONFIG_SCHEMA,
), **{ "permitted_keys": PERMITTED_KEYS["wled_preferences"] }},
"schema": {
**convertToJsonSchema(
WLED_CONFIG_SCHEMA,
),
**{
"permitted_keys": PERMITTED_KEYS[
"wled_preferences"
]
},
},
}
elif schema == "core":
# Get core config schema
response["core"] = {
"schema": {**convertToJsonSchema(
CORE_CONFIG_SCHEMA
), **{ "permitted_keys": PERMITTED_KEYS["core"] }},
"schema": {
**convertToJsonSchema(CORE_CONFIG_SCHEMA),
**{"permitted_keys": PERMITTED_KEYS["core"]},
},
}
return web.json_response(data=response, status=200)

View File

@ -136,7 +136,10 @@ class EffectsEndpoint(RestEndpoint):
effect = self._ledfx.effects.create(
ledfx=self._ledfx,
type=effect_type,
config={**virtual.active_effect.config, **effect_config},
config={
**virtual.active_effect.config,
**effect_config,
},
)
virtual.set_effect(effect)
else:

View File

@ -257,14 +257,13 @@ class WebsocketConnection:
# message.get("data") HERE IT IS BROOOO
)
)
# ToDo:
# ToDo:
# Remove the log on each message, and just log once
# # create virtual audio device with:
# name = f"WEB: {message.get("client")}"
# data = message.get("data")
@websocket_handler("audio_data_end")
def unsubscribe_event_handler(self, message):

View File

@ -59,7 +59,7 @@ class AdalightDevice(Device):
): vol.All(vol.Coerce(int), vol.Range(min=115200)),
vol.Required(
"pixel_count",
description="Number of individual pixels",
description="Number of individual pixels",
default=1,
): vol.All(vol.Coerce(int), vol.Range(min=1)),
vol.Required(

View File

@ -40,7 +40,7 @@ class DDPDevice(NetworkedDevice):
): str,
vol.Required(
"pixel_count",
description="Number of individual pixels",
description="Number of individual pixels",
default=1,
): int,
}

View File

@ -92,9 +92,7 @@ class E131Device(NetworkedDevice):
):
_LOGGER.info(f"sACN activating universe {universe}")
self._sacn.activate_output(universe)
self._sacn[universe].priority = self._config[
"packet_priority"
]
self._sacn[universe].priority = self._config["packet_priority"]
self._sacn[universe].multicast = multicast
if not multicast:
self._sacn[universe].destination = self.destination

View File

@ -60,11 +60,11 @@ class BladePowerPlus(AudioReactiveEffect, HSVEffect, GradientEffect):
description="Invert the direction of the gradient roll",
default=False,
): bool,
#vol.Optional(
# vol.Optional(
# "blade_color",
# description="NEW Color",
# default="hsl(0, 100%, 25%)",
#): str,
# ): str,
}
)

View File

@ -451,10 +451,13 @@ class Melbanks:
self.melbank_processors = tuple(
Melbank(
self._audio,
{**self.DEFAULT_MELBANK_CONFIG, **{
"max_frequency": freq,
# "pre_emphasis": self.MELBANK_PRE_EMPHASIS[i],
}},
{
**self.DEFAULT_MELBANK_CONFIG,
**{
"max_frequency": freq,
# "pre_emphasis": self.MELBANK_PRE_EMPHASIS[i],
},
},
)
for i, freq in enumerate(self._config["max_frequencies"])
)

View File

@ -62,7 +62,7 @@ class QLC(Integration):
self.restore_from_data(data)
def restore_from_data(self, data):
""" Creates the event listeners from saved data """
"""Creates the event listeners from saved data"""
if data is not None:
try:
for entry in data:
@ -84,7 +84,7 @@ class QLC(Integration):
return self._data
def create_event(self, event_type, event_filter, active, qlc_payload):
""" Create or update event listener that sends a qlc payload on a specific event """
"""Create or update event listener that sends a qlc payload on a specific event"""
# If it exists, remove the existing listener and update data
for idx, entry in enumerate(self._data):
_event_type, _event_filter, _active, _qlc_payload = entry
@ -110,7 +110,7 @@ class QLC(Integration):
)
def delete_event(self, event_type, event_filter):
""" Completely delete event listener and saved payload from data """
"""Completely delete event listener and saved payload from data"""
# remove listener if it exists
self._remove_listener(event_type, event_filter)
# remove event and payload from data
@ -123,7 +123,7 @@ class QLC(Integration):
)
def toggle_event(self, event_type, event_filter):
""" Toggle a payload linked to event on or off """
"""Toggle a payload linked to event on or off"""
# Update "active" flag in data
for idx, entry in enumerate(self._data):
_event_type, _event_filter, _active, _qlc_payload = entry
@ -149,7 +149,7 @@ class QLC(Integration):
return False # failed to find event_type with this event_filter
def _remove_listener(self, event_type, event_filter):
""" Internal function to remove ledfx events listener if it exists """
"""Internal function to remove ledfx events listener if it exists"""
for idx, entry in enumerate(self._listeners):
_event_type, _event_filter, listener = entry
if (_event_type == event_type) and (_event_filter == event_filter):
@ -159,7 +159,7 @@ class QLC(Integration):
break
def _add_listener(self, event_type, event_filter, qlc_payload):
""" Internal function that links payload to send on the specified event """
"""Internal function that links payload to send on the specified event"""
def make_callback(qlc_payload):
def callback(_):
@ -180,7 +180,7 @@ class QLC(Integration):
self._listeners.append((event_type, event_filter, listener))
async def get_widgets(self):
""" Returns a list of widgets as tuples: [(ID, Type, Name),...] """
"""Returns a list of widgets as tuples: [(ID, Type, Name),...]"""
# First get list of widgets (ID, Name)
widgets = []
message = "QLC+API|getWidgetsList"
@ -198,7 +198,7 @@ class QLC(Integration):
return widgets
async def _send_payload(self, qlc_payload):
""" Sends payload of {id:value, ...} pairs to QLC"""
"""Sends payload of {id:value, ...} pairs to QLC"""
for widget_id, value in qlc_payload.items():
await self._client.send(f"{int(widget_id)}|{value}")

View File

@ -51,21 +51,21 @@ class Spotify(Integration):
self.restore_from_data(data)
def restore_from_data(self, data):
""" Might be used in future """
"""Might be used in future"""
self._data = data
def get_triggers(self):
return self._data
def add_trigger(self, scene_id, song_id, song_name, song_position):
""" Add a trigger to saved triggers"""
"""Add a trigger to saved triggers"""
trigger_id = f"{song_id}-{str(song_position)}"
if scene_id not in self._data.keys():
self._data[scene_id] = {}
self._data[scene_id][trigger_id] = [song_id, song_name, song_position]
def delete_trigger(self, trigger_id):
""" Delete a trigger from saved triggers"""
"""Delete a trigger from saved triggers"""
for scene_id in self._data.keys():
if trigger_id in self._data[scene_id].keys():
del self._data[scene_id][trigger_id]

View File

@ -1063,9 +1063,9 @@ ledfx_presets = {
"invert_roll": False,
"mirror": True,
"multiplier": 1,
"solid_color": False
"solid_color": False,
},
"name": "Hi Hat"
"name": "Hi Hat",
},
"ocean": {
"config": {
@ -1083,10 +1083,10 @@ ledfx_presets = {
"invert_roll": False,
"mirror": False,
"multiplier": 0.5,
"solid_color": False
"solid_color": False,
},
"name": "Ocean"
}
"name": "Ocean",
},
},
"bands": {"reset": {"config": {}, "name": "Reset"}},
"bands_matrix": {"reset": {"config": {}, "name": "Reset"}},