If you work remotely for work from home and second home what state do you report income?

If you work remotely for work and work from home in both your primary home an second home what state do you report the income? Do you report all the income in one state? If you split how do you split? Does it matter where the office is? If you go into the office once a week does that matter?