mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
betterneato
This commit is contained in:
@@ -27,6 +27,7 @@ export default function VipPanel() {
|
||||
neatoSendHome,
|
||||
neatoLocate,
|
||||
neatoClearErrors,
|
||||
neatoPowerCycle,
|
||||
liftUp,
|
||||
liftDown,
|
||||
} = useSession();
|
||||
@@ -81,6 +82,7 @@ export default function VipPanel() {
|
||||
onSendHome={neatoSendHome}
|
||||
onLocate={neatoLocate}
|
||||
onClearErrors={neatoClearErrors}
|
||||
onPowerCycle={neatoPowerCycle}
|
||||
fullWidth
|
||||
/>
|
||||
<VipLiftCard
|
||||
|
||||
@@ -44,6 +44,7 @@ export default function VipNeatoCard({
|
||||
onSendHome,
|
||||
onLocate,
|
||||
onClearErrors,
|
||||
onPowerCycle,
|
||||
fullWidth = false,
|
||||
}) {
|
||||
const [working, setWorking] = useState('');
|
||||
@@ -71,11 +72,13 @@ export default function VipNeatoCard({
|
||||
const canSendHome = Boolean(controls?.sendHome?.available);
|
||||
const canLocate = Boolean(controls?.locate?.available);
|
||||
const canClearErrors = Boolean(controls?.clearErrors?.available);
|
||||
const canPowerCycle = Boolean(controls?.powerCycle?.available);
|
||||
|
||||
const canRunStart = configured && connected && canStart;
|
||||
const canRunSendHome = configured && connected && canSendHome;
|
||||
const canRunLocate = configured && connected && canLocate;
|
||||
const canRunClearErrors = configured && connected && canClearErrors;
|
||||
const canRunPowerCycle = configured && connected && canPowerCycle;
|
||||
|
||||
const runAction = async (key, fn) => {
|
||||
if (!fn) return;
|
||||
@@ -131,7 +134,7 @@ export default function VipNeatoCard({
|
||||
>
|
||||
{working === 'sendHome' ? 'Sending...' : 'Send to dock'}
|
||||
</button>
|
||||
<div className="grid grid-cols-2 gap-0.5">
|
||||
<div className="grid grid-cols-3 gap-0.5">
|
||||
<button
|
||||
type="button"
|
||||
disabled={!canRunLocate || Boolean(working)}
|
||||
@@ -148,6 +151,14 @@ export default function VipNeatoCard({
|
||||
>
|
||||
{working === 'clearErrors' ? 'Clearing...' : 'Clear errors'}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={!canRunPowerCycle || Boolean(working)}
|
||||
onClick={() => runAction('powerCycle', onPowerCycle)}
|
||||
className="w-full rounded-md border border-rose-300 bg-rose-600 px-1 py-0.5 text-xs font-semibold text-white transition hover:border-rose-500 hover:bg-rose-500 disabled:opacity-50"
|
||||
>
|
||||
{working === 'powerCycle' ? 'Cycling...' : 'Power cycle'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="surface-muted grid gap-0.5 pt-0.25">
|
||||
<p className="text-xs text-slate-300 text-center">Power status</p>
|
||||
@@ -195,7 +206,7 @@ export default function VipNeatoCard({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!configured || !connected || !canStart || !canSendHome || !canLocate || !canClearErrors ? (
|
||||
{!configured || !connected || !canStart || !canSendHome || !canLocate || !canClearErrors || !canPowerCycle ? (
|
||||
<p className="text-xs text-slate-400 text-center">
|
||||
{!configured
|
||||
? 'Set homeAssistant.neato.device in server config to enable Neato controls.'
|
||||
|
||||
@@ -169,6 +169,7 @@ export function SessionProvider({ children }) {
|
||||
neatoSendHome: () => emitWithAck('neato:sendHome'),
|
||||
neatoLocate: () => emitWithAck('neato:locate'),
|
||||
neatoClearErrors: () => emitWithAck('neato:clearErrors'),
|
||||
neatoPowerCycle: () => emitWithAck('neato:powerCycle'),
|
||||
liftUp: () => emitWithAck('lift:up'),
|
||||
liftDown: () => emitWithAck('lift:down'),
|
||||
setNickname: (nickname) => emitWithAck('nickname:set', { nickname }),
|
||||
|
||||
Reference in New Issue
Block a user